-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Drapeza Oleg <[email protected]> GitOrigin-RevId: 8e3669f14da3a576c03d20b7366d91b57970e489
- Loading branch information
1 parent
ae447fb
commit 599672c
Showing
42 changed files
with
650 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { lazy, useDi } from '@tramvai/react'; | ||
import { useState } from 'react'; | ||
import { CHILD_APP_BASE_TOKEN } from './tokens'; | ||
|
||
const Lazy = lazy(() => import('./lazy-cmp')); | ||
|
||
const LazyUnused = lazy(() => import('./lazy-cmp-unused')); | ||
|
||
export const LoadableCmp = ({ fromRoot }: { fromRoot: string }) => { | ||
const [visible, setVisible] = useState(false); | ||
const val = useDi(CHILD_APP_BASE_TOKEN); | ||
|
||
return ( | ||
<> | ||
<Lazy /> | ||
<div id="loadable">Child App: {val}</div> | ||
<button id="loadable-toggle" type="button" onClick={() => setVisible((prev) => !prev)}> | ||
toggle unused component | ||
</button> | ||
{visible && <LazyUnused />} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { createChildApp } from '@tramvai/child-app-core'; | ||
import { createAction, provide } from '@tramvai/core'; | ||
import { CommonChildAppModule } from '@tramvai/module-common'; | ||
import { LoadableCmp } from './component'; | ||
import { CHILD_APP_BASE_TOKEN } from './tokens'; | ||
|
||
declare global { | ||
interface Window { | ||
TRAMVAI_TEST_CHILD_APP_NOT_PRELOADED_ACTION_CALL_NUMBER: number; | ||
} | ||
} | ||
|
||
if (typeof window !== 'undefined') { | ||
window.TRAMVAI_TEST_CHILD_APP_NOT_PRELOADED_ACTION_CALL_NUMBER = 0; | ||
} | ||
|
||
const action = createAction({ | ||
name: 'action', | ||
fn() { | ||
window.TRAMVAI_TEST_CHILD_APP_NOT_PRELOADED_ACTION_CALL_NUMBER++; | ||
}, | ||
conditions: { | ||
always: true, | ||
onlyBrowser: true, | ||
}, | ||
}); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default createChildApp({ | ||
name: 'base', | ||
render: LoadableCmp, | ||
modules: [CommonChildAppModule], | ||
actions: [action], | ||
providers: [ | ||
provide({ | ||
provide: CHILD_APP_BASE_TOKEN, | ||
useValue: "I'm little child app", | ||
}), | ||
], | ||
}); |
3 changes: 3 additions & 0 deletions
3
examples/child-app/child-apps/loadable/lazy-cmp-unused.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.LazyCmp { | ||
color: green; | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/child-app/child-apps/loadable/lazy-cmp-unused.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as dateFns from 'date-fns'; | ||
import cn from './lazy-cmp-unused.module.css'; | ||
|
||
console.log(dateFns); | ||
|
||
export const LazyCmp = () => { | ||
return ( | ||
<> | ||
<h2 className={cn.LazyCmp}>Lazy Unused</h2> | ||
</> | ||
); | ||
}; | ||
|
||
export default LazyCmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.LazyCmp { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as dateFns from 'date-fns'; | ||
import cn from './lazy-cmp.module.css'; | ||
|
||
console.log(dateFns); | ||
|
||
export const LazyCmp = () => { | ||
return ( | ||
<> | ||
<h2 className={cn.LazyCmp}>Lazy</h2> | ||
</> | ||
); | ||
}; | ||
|
||
export default LazyCmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { createToken } from '@tinkoff/dippy'; | ||
|
||
export const CHILD_APP_BASE_TOKEN = createToken<string>('children base token'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { PageComponent } from '@tramvai/react'; | ||
import { createBundle } from '@tramvai/core'; | ||
import { ChildApp } from '@tramvai/module-child-app'; | ||
|
||
const Cmp: PageComponent = () => { | ||
return ( | ||
<> | ||
<div>Content from root</div> | ||
<ChildApp name="loadable" /> | ||
</> | ||
); | ||
}; | ||
|
||
Cmp.childApps = [{ name: 'loadable' }]; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default createBundle({ | ||
name: 'loadable', | ||
components: { | ||
pageDefault: Cmp, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
{"@tramvai/cli":"3.27.5","@tramvai/swc-integration":"3.27.5","@tinkoff/browser-timings":"0.11.1","@tinkoff/browserslist-config":"0.3.2","@tinkoff/browser-cookies":"3.0.1","@tinkoff/dippy":"0.9.2","@tinkoff/env-validators":"0.2.1","@tinkoff/error-handlers":"0.6.1","@tinkoff/errors":"0.4.2","@tinkoff/eslint-plugin-tramvai":"0.7.3","@tinkoff/hook-runner":"0.5.1","@tramvai/http-client":"0.3.1","@tinkoff/is-modern-lib":"3.0.3","@tramvai/react-lazy-hydration-render":"0.3.1","@tinkoff/logger":"0.10.170","@tinkoff/pack-polyfills":"0.5.1","@tinkoff/measure-express-requests":"3.0.1","@tinkoff/measure-fastify-requests":"0.2.1","@tinkoff/meta-tags-generate":"0.6.1","@tinkoff/metrics-noop":"3.0.1","@tinkoff/minicss-class-generator":"0.3.1","@tinkoff/mocker":"3.0.1","@tinkoff/module-loader-client":"0.5.1","@tinkoff/module-loader-server":"0.6.2","@tinkoff/monkeypatch":"3.0.1","@tinkoff/package-manager-wrapper":"0.2.2","@tinkoff/htmlpagebuilder":"0.6.1","prettier-config-tinkoff":"0.3.1","@tinkoff/pubsub":"0.6.1","@tinkoff/react-hooks":"0.2.1","@tinkoff/router":"0.3.52","@tramvai/safe-strings":"0.6.2","@tinkoff/terminus":"0.2.1","@tinkoff/layout-factory":"0.4.1","@tramvai/tinkoff-request-http-client-adapter":"0.10.72","@tinkoff/url":"0.9.2","@tinkoff/user-agent":"0.5.72","@tinkoff/webpack-dedupe-plugin":"2.0.2","@tramvai/module-autoscroll":"3.27.5","@tramvai/module-cache-warmup":"3.27.5","@tramvai/module-child-app":"3.27.5","@tramvai/module-client-hints":"3.27.5","@tramvai/module-common":"3.27.5","@tramvai/module-cookie":"3.27.5","@tramvai/module-deps-graph":"3.27.5","@tramvai/module-dns-cache":"3.27.5","@tramvai/module-environment":"3.27.5","@tramvai/module-error-interceptor":"3.27.5","@tramvai/module-http-client":"3.27.5","@tramvai/module-http-proxy-agent":"3.27.5","@tramvai/module-log":"3.27.5","@tramvai/module-metrics":"3.27.5","@tramvai/module-micro-sentry":"3.27.5","@tramvai/module-mocker":"3.27.5","@tramvai/module-page-render-mode":"3.27.5","@tramvai/module-progressive-web-app":"3.27.5","@tramvai/module-react-query":"3.27.5","@tramvai/module-render":"3.27.5","@tramvai/module-request-limiter":"3.27.5","@tramvai/module-router":"3.27.5","@tramvai/module-sentry":"3.27.5","@tramvai/module-seo":"3.27.5","@tramvai/module-server":"3.27.5","@tramvai/tokens-child-app":"3.27.5","@tramvai/tokens-common":"3.27.5","@tramvai/tokens-cookie":"3.27.5","@tramvai/tokens-core":"3.27.5","@tramvai/tokens-core-private":"3.27.5","@tramvai/tokens-http-client":"3.27.5","@tramvai/tokens-metrics":"3.27.5","@tramvai/tokens-react-query":"3.27.5","@tramvai/tokens-render":"3.27.5","@tramvai/tokens-router":"3.27.5","@tramvai/tokens-server":"3.27.5","@tramvai/tokens-server-private":"3.27.5","@tramvai/child-app-core":"3.27.5","@tramvai/core":"3.27.5","@tramvai/experiments":"3.27.5","@tramvai/papi":"3.27.5","@tramvai/pwa-recipes":"3.27.5","@tramvai/react":"3.27.5","@tramvai/react-query":"3.27.5","@tramvai/state":"3.27.5","@tramvai/storybook-addon":"3.27.5","@tramvai/types-actions-state-context":"3.27.5","@tramvai/test-child-app":"3.27.5","@tramvai/test-helpers":"3.27.5","@tramvai/test-integration":"3.27.5","@tramvai/test-integration-jest":"3.27.5","@tramvai/test-jsdom":"3.27.5","@tramvai/test-mocks":"3.27.5","@tramvai/test-pw":"3.27.5","@tramvai/test-puppeteer":"3.27.5","@tramvai/test-react":"3.27.5","@tramvai/test-unit":"3.27.5","@tramvai/test-unit-jest":"3.27.5","@tramvai/build":"4.1.1","@tramvai/tools-check-versions":"0.5.3","@tramvai/create":"3.27.5","@tramvai/tools-generate-schema":"0.2.1","@tramvai/tools-migrate":"0.7.3","@tinkoff-monorepo/depscheck":"3.0.2","@tinkoff-monorepo/fix-ts-references":"3.0.2","@tinkoff-monorepo/pkgs-collector":"3.0.2","@tinkoff-monorepo/pkgs-collector-dir":"3.0.2","@tinkoff-monorepo/pkgs-collector-workspaces":"3.0.2"} | ||
{"@tramvai/cli":"3.28.0","@tramvai/swc-integration":"3.28.0","@tinkoff/browser-timings":"0.11.1","@tinkoff/browserslist-config":"0.3.2","@tinkoff/browser-cookies":"3.0.1","@tinkoff/dippy":"0.9.2","@tinkoff/env-validators":"0.2.1","@tinkoff/error-handlers":"0.6.1","@tinkoff/errors":"0.4.2","@tinkoff/eslint-plugin-tramvai":"0.7.3","@tinkoff/hook-runner":"0.5.1","@tramvai/http-client":"0.3.1","@tinkoff/is-modern-lib":"3.0.3","@tramvai/react-lazy-hydration-render":"0.3.1","@tinkoff/logger":"0.10.170","@tinkoff/pack-polyfills":"0.5.1","@tinkoff/measure-express-requests":"3.0.1","@tinkoff/measure-fastify-requests":"0.2.1","@tinkoff/meta-tags-generate":"0.6.1","@tinkoff/metrics-noop":"3.0.1","@tinkoff/minicss-class-generator":"0.3.1","@tinkoff/mocker":"3.0.1","@tinkoff/module-loader-client":"0.5.1","@tinkoff/module-loader-server":"0.6.3","@tinkoff/monkeypatch":"3.0.1","@tinkoff/package-manager-wrapper":"0.2.2","@tinkoff/htmlpagebuilder":"0.6.1","prettier-config-tinkoff":"0.3.1","@tinkoff/pubsub":"0.6.1","@tinkoff/react-hooks":"0.2.1","@tinkoff/router":"0.3.53","@tramvai/safe-strings":"0.6.2","@tinkoff/terminus":"0.2.1","@tinkoff/layout-factory":"0.4.1","@tramvai/tinkoff-request-http-client-adapter":"0.10.73","@tinkoff/url":"0.9.2","@tinkoff/user-agent":"0.5.73","@tinkoff/webpack-dedupe-plugin":"2.0.2","@tramvai/module-autoscroll":"3.28.0","@tramvai/module-cache-warmup":"3.28.0","@tramvai/module-child-app":"3.28.0","@tramvai/module-client-hints":"3.28.0","@tramvai/module-common":"3.28.0","@tramvai/module-cookie":"3.28.0","@tramvai/module-deps-graph":"3.28.0","@tramvai/module-dns-cache":"3.28.0","@tramvai/module-environment":"3.28.0","@tramvai/module-error-interceptor":"3.28.0","@tramvai/module-http-client":"3.28.0","@tramvai/module-http-proxy-agent":"3.28.0","@tramvai/module-log":"3.28.0","@tramvai/module-metrics":"3.28.0","@tramvai/module-micro-sentry":"3.28.0","@tramvai/module-mocker":"3.28.0","@tramvai/module-page-render-mode":"3.28.0","@tramvai/module-progressive-web-app":"3.28.0","@tramvai/module-react-query":"3.28.0","@tramvai/module-render":"3.28.0","@tramvai/module-request-limiter":"3.28.0","@tramvai/module-router":"3.28.0","@tramvai/module-sentry":"3.28.0","@tramvai/module-seo":"3.28.0","@tramvai/module-server":"3.28.0","@tramvai/tokens-child-app":"3.28.0","@tramvai/tokens-common":"3.28.0","@tramvai/tokens-cookie":"3.28.0","@tramvai/tokens-core":"3.28.0","@tramvai/tokens-core-private":"3.28.0","@tramvai/tokens-http-client":"3.28.0","@tramvai/tokens-metrics":"3.28.0","@tramvai/tokens-react-query":"3.28.0","@tramvai/tokens-render":"3.28.0","@tramvai/tokens-router":"3.28.0","@tramvai/tokens-server":"3.28.0","@tramvai/tokens-server-private":"3.28.0","@tramvai/child-app-core":"3.28.0","@tramvai/core":"3.28.0","@tramvai/experiments":"3.28.0","@tramvai/papi":"3.28.0","@tramvai/pwa-recipes":"3.28.0","@tramvai/react":"3.28.0","@tramvai/react-query":"3.28.0","@tramvai/state":"3.28.0","@tramvai/storybook-addon":"3.28.0","@tramvai/types-actions-state-context":"3.28.0","@tramvai/test-child-app":"3.28.0","@tramvai/test-helpers":"3.28.0","@tramvai/test-integration":"3.28.0","@tramvai/test-integration-jest":"3.28.0","@tramvai/test-jsdom":"3.28.0","@tramvai/test-mocks":"3.28.0","@tramvai/test-pw":"3.28.0","@tramvai/test-puppeteer":"3.28.0","@tramvai/test-react":"3.28.0","@tramvai/test-unit":"3.28.0","@tramvai/test-unit-jest":"3.28.0","@tramvai/build":"4.1.1","@tramvai/tools-check-versions":"0.5.3","@tramvai/create":"3.28.0","@tramvai/tools-generate-schema":"0.2.1","@tramvai/tools-migrate":"0.7.3","@tinkoff-monorepo/depscheck":"3.0.2","@tinkoff-monorepo/fix-ts-references":"3.0.2","@tinkoff-monorepo/pkgs-collector":"3.0.2","@tinkoff-monorepo/pkgs-collector-dir":"3.0.2","@tinkoff-monorepo/pkgs-collector-workspaces":"3.0.2"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.