Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: use runtime api #2908

Open
wants to merge 124 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
329e7c8
feat: async chunk startup
ScriptedAlchemy Aug 1, 2024
f7b685e
feat: async chunk startup
ScriptedAlchemy Aug 6, 2024
5483925
Merge branch 'refs/heads/main' into feat/async-entry-startup
ScriptedAlchemy Aug 6, 2024
aeef5a5
feat: async chunk startup
ScriptedAlchemy Aug 6, 2024
c8227ad
Merge branch 'refs/heads/main' into feat/async-entry-startup
ScriptedAlchemy Aug 6, 2024
6eda7ab
chore: locks
ScriptedAlchemy Aug 6, 2024
2b55aa1
fix: next server startup
ScriptedAlchemy Aug 8, 2024
24c429d
feat: embed runtime
ScriptedAlchemy Aug 14, 2024
52e67d8
feat: embed runtime
ScriptedAlchemy Aug 15, 2024
f2fcea5
fix: early return runtime module if exists on compile
ScriptedAlchemy Aug 15, 2024
386e67f
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 15, 2024
392f2f1
fix(enhanced): split runtime from chunk content
ScriptedAlchemy Aug 16, 2024
4e0bd89
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 16, 2024
48cd80a
chore: improve child compiler
ScriptedAlchemy Aug 16, 2024
80990b9
chore: improve child compiler
ScriptedAlchemy Aug 19, 2024
ac8de04
chore: improve child compiler
ScriptedAlchemy Aug 19, 2024
dd93b8c
fix(nextjs-mf): re-enable module hoisting
ScriptedAlchemy Aug 19, 2024
6dfcd89
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 19, 2024
0cca993
fix(enhanced): refactor runtime module addition hooks
ScriptedAlchemy Aug 19, 2024
fe8477e
fix(enhanced): refactor runtime module addition hooks
ScriptedAlchemy Aug 19, 2024
542da0c
fix(enhanced): runtime requirement once for chunk set
ScriptedAlchemy Aug 19, 2024
f14d9db
fix: enable chunk hoisting
ScriptedAlchemy Aug 20, 2024
04d615e
chore: next in working state again
ScriptedAlchemy Aug 21, 2024
4b5c62f
fix: improve module hoisting
ScriptedAlchemy Aug 21, 2024
88dc18c
fix: improve module hoisting
ScriptedAlchemy Aug 21, 2024
fa90cc2
chore: lint
ScriptedAlchemy Aug 21, 2024
3380f31
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 21, 2024
2f39075
chore: update deps
ScriptedAlchemy Aug 21, 2024
371c73e
chore: fix types
ScriptedAlchemy Aug 22, 2024
8068644
fix: prevent runtime module injection on mini css
ScriptedAlchemy Aug 22, 2024
db6d311
fix(enhanced): fix missing module cache crash in macro
ScriptedAlchemy Aug 22, 2024
452136e
fix(enhanced): fix missing module cache crash in macro
ScriptedAlchemy Aug 22, 2024
163c1ab
fix(enhanced): fix runtime requirements chuck on single entry runtime
ScriptedAlchemy Aug 22, 2024
3ed827d
fix(enhanced): fix runtime requirements chuck on single entry runtime
ScriptedAlchemy Aug 22, 2024
7e9b323
fix(enhanced): fix runtime requirements chuck on single entry runtime
ScriptedAlchemy Aug 22, 2024
9d8849e
fix(enhanced): use normal webpack version
ScriptedAlchemy Aug 22, 2024
d9245b0
fix(enhanced): use normal webpack version
ScriptedAlchemy Aug 22, 2024
58b5287
fix(enhanced): use and set chunk runtime requirements not tree requir…
ScriptedAlchemy Aug 22, 2024
f8c1429
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 22, 2024
935d745
fix(enhanced): use and set chunk runtime requirements not tree requir…
ScriptedAlchemy Aug 22, 2024
6d1bcf0
fix(enhanced): use and set chunk runtime requirements not tree requir…
ScriptedAlchemy Aug 22, 2024
1377301
chore: update webpack types
ScriptedAlchemy Aug 22, 2024
a93ccf8
fix: resolve type match issues with webpack
ScriptedAlchemy Aug 23, 2024
1835c31
chore: use tree runtime requirement
ScriptedAlchemy Aug 23, 2024
770d6ac
chore: use tree runtime requirement
ScriptedAlchemy Aug 23, 2024
6f6fbe3
fix(nextjs-mf): add container embedding back for now
ScriptedAlchemy Aug 23, 2024
4d49017
fix(enhanced): inject runtime module into apps missing other requrements
ScriptedAlchemy Aug 23, 2024
d6428d9
fix(enhanced): implement fs cache
ScriptedAlchemy Aug 23, 2024
83b9684
fix(enhanced): fix runtime requiremetns additions
ScriptedAlchemy Aug 24, 2024
c1f1db5
fix(enhanced): simplify chunk tree requirements
ScriptedAlchemy Aug 24, 2024
13ef415
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 24, 2024
e898b50
chore: clean up types
ScriptedAlchemy Aug 24, 2024
8f4f253
fix: clean up loggers
ScriptedAlchemy Aug 24, 2024
2e87014
chore: changesets
ScriptedAlchemy Aug 24, 2024
fd67a66
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 28, 2024
6da5201
feat(enhanced): drop child compiler from runtime module (#2884)
ScriptedAlchemy Aug 28, 2024
fc0c80d
chore: remove useless changes
ScriptedAlchemy Aug 28, 2024
38f9503
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 29, 2024
c45d834
chore: update ignore
ScriptedAlchemy Aug 29, 2024
e76b7dc
chore: update ignore
ScriptedAlchemy Aug 29, 2024
10a06a7
chore: reset global ts
ScriptedAlchemy Aug 29, 2024
d8f8d45
chore: reset container entry module
ScriptedAlchemy Aug 29, 2024
05152f1
chore: update gitignore
ScriptedAlchemy Aug 29, 2024
4d5ae5e
chore: reset example code
ScriptedAlchemy Aug 29, 2024
963c781
chore: formatting
ScriptedAlchemy Aug 29, 2024
658680b
chore: preserve child compiler plugin version from git history
ScriptedAlchemy Aug 29, 2024
583dd0d
chore: remove commented out code
ScriptedAlchemy Aug 29, 2024
f3992a1
fix(enhanced): fix type issue on runtime plugin
ScriptedAlchemy Aug 29, 2024
8998977
fix(enhanced): rename plugins
ScriptedAlchemy Aug 29, 2024
17a24b7
fix(enhanced): remove logs
ScriptedAlchemy Aug 29, 2024
5315492
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 29, 2024
e5e25f1
Merge branch 'feat/embed-runtime' into embed-next-wotrking
ScriptedAlchemy Aug 29, 2024
66be91a
fix(enhanced): remove logs
ScriptedAlchemy Aug 29, 2024
a6823cf
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 29, 2024
50c12dc
Merge branch 'feat/embed-runtime' into embed-next-wotrking
ScriptedAlchemy Aug 29, 2024
c19449e
fix(enhanced): enable federation runtime always
ScriptedAlchemy Aug 29, 2024
06f5717
fix(enhanced): enable federation runtime always
ScriptedAlchemy Aug 29, 2024
5df5856
fix(enhanced): fix merge issues
ScriptedAlchemy Aug 29, 2024
6383d6e
fix(enhanced): fix merge issues
ScriptedAlchemy Aug 29, 2024
dd885d7
fix(enhanced): fix merge issues
ScriptedAlchemy Aug 29, 2024
e3889cb
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 29, 2024
ba22ba7
chore: ignore cypress/downloads
ScriptedAlchemy Aug 29, 2024
1482dfd
Merge remote-tracking branch 'origin/main' into embed-next-wotrking
ScriptedAlchemy Aug 29, 2024
999263f
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 30, 2024
f963915
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 30, 2024
f70f97c
Merge branch 'feat/embed-runtime' into embed-next-wotrking
ScriptedAlchemy Aug 30, 2024
caf9bb3
fix(enhanced): remove embedded runtime resolve paths
ScriptedAlchemy Aug 30, 2024
0b1fd2b
Merge branch 'feat/embed-runtime' into embed-next-wotrking
ScriptedAlchemy Aug 30, 2024
8007020
chore: enable embed runtime (#2900)
2heal1 Aug 30, 2024
d1c7980
fix(enhanced): remove embedded runtime resolve paths
ScriptedAlchemy Aug 30, 2024
f3e297b
Merge branch 'main' into embed-next-wotrking
ScriptedAlchemy Aug 30, 2024
d232bb8
chore(nextjs-mf): replace some type imports
ScriptedAlchemy Aug 30, 2024
5a68c1b
chore(nextjs-mf): replace some type imports
ScriptedAlchemy Aug 30, 2024
db16bc6
chore(nextjs-mf): replace some type imports
ScriptedAlchemy Aug 30, 2024
535b310
chore(nextjs-mf): replace some type imports
ScriptedAlchemy Aug 30, 2024
2aaff9d
chore(nextjs-mf): replace some type imports
ScriptedAlchemy Aug 30, 2024
7ba706a
feat(enhanced): eager runtime (#2874)
ScriptedAlchemy Aug 30, 2024
e9dd267
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 30, 2024
8b78b5c
chore: use runtime api demo
2heal1 Aug 30, 2024
6f05560
Merge branch 'main' into chore/use-runtime-api
ScriptedAlchemy Aug 30, 2024
9902b10
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Aug 30, 2024
5b5b1b5
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
af054d4
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Aug 30, 2024
3610464
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
5a79281
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Aug 30, 2024
8698b54
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
70d8547
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
fef2d67
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
912f492
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Aug 30, 2024
05a20b2
Merge remote-tracking branch 'origin/chore/use-runtime-api' into chor…
ScriptedAlchemy Aug 30, 2024
3d4c8bb
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
2dacf87
fix(enhanced): startup helper check runtime reqs of handler
ScriptedAlchemy Aug 30, 2024
adad550
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Aug 30, 2024
00ab0d7
fix(enhanced): set bundler runtime as used in unknown way
ScriptedAlchemy Aug 30, 2024
69b295a
fix(enhanced): pass entry and bundler runtime to hoist plugin
ScriptedAlchemy Aug 31, 2024
203337e
ci: update build for next dev and prod jobs
ScriptedAlchemy Aug 31, 2024
4085f41
ci: update build for next dev and prod jobs
ScriptedAlchemy Aug 31, 2024
8c7d8d2
ci: update build for next dev and prod jobs
ScriptedAlchemy Aug 31, 2024
e8f238f
Merge branch 'main' into feat/embed-runtime
ScriptedAlchemy Aug 31, 2024
dd1e74e
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Aug 31, 2024
7156105
fix(enhanced): do not use embedded bundler runtime
ScriptedAlchemy Sep 2, 2024
3c66f93
fix(enhanced): do not use embedded bundler runtime
ScriptedAlchemy Sep 2, 2024
04d47ff
fix(enhanced): align wrapper plugins with actual
ScriptedAlchemy Sep 2, 2024
78e367c
Merge branch 'feat/embed-runtime' into chore/use-runtime-api
ScriptedAlchemy Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/chatty-hornets-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@module-federation/nextjs-mf': minor
'@module-federation/enhanced': minor
---

enable chunk hoisting when runtime is embedded
5 changes: 5 additions & 0 deletions .changeset/kind-nails-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/enhanced': minor
---

Embedded runtime and async entry startup
11 changes: 8 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Affected Packages

on:
pull_request:
branches: [main]
branches: [main, '**']
push:
branches: [main]

Expand Down Expand Up @@ -62,9 +62,14 @@ jobs:
uses: ./.github/workflows/e2e-node.yml
secrets: inherit

e2e-next:
e2e-next-dev:
needs: checkout-install
uses: ./.github/workflows/e2e-next-dev.yml
secrets: inherit

e2e-next-prod:
needs: checkout-install
uses: ./.github/workflows/e2e-next.yml
uses: ./.github/workflows/e2e-next-prod.yml
secrets: inherit

e2e-modern-ssr:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:

- name: E2E Test for Manifest Demo
if: steps.check-ci.outcome == 'success'
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=1 && lsof -ti tcp:3013,3009,3010,3011,3012 | xargs kill
run: pnpm run app:manifest:dev & echo "done" && sleep 15 && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=1 && lsof -ti tcp:3013,3009,3010,3011,3012 | xargs kill
52 changes: 52 additions & 0 deletions .github/workflows/e2e-next-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: E2E Test for Next.js Dev

on:
workflow_call:

jobs:
e2e-next-dev:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Pnpm
run: corepack enable

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Set Nx SHA
uses: nrwl/nx-set-shas@v3

- name: Set SKIP_DEVTOOLS_POSTINSTALL environment variable
run: echo "SKIP_DEVTOOLS_POSTINSTALL=true" >> $GITHUB_ENV

- name: Install Dependencies
run: pnpm install

- name: Install Cypress
run: npx cypress install

- name: Run Build for All
run: npx nx run-many --targets=build --projects=tag:type:pkg

- name: Run condition check script
id: check-ci
run: node tools/scripts/ci-is-affected.mjs --appName=3000-home

- name: E2E Test for Next.js Dev
if: steps.check-ci.outcome == 'success'
run: |
pnpm run app:next:dev > /dev/null 2>&1 &
sleep 1 &&
npx wait-on tcp:3001 &&
npx wait-on tcp:3002 &&
npx wait-on tcp:3000 &&
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
lsof -ti tcp:3000,3001,3002 | xargs kill
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# .github/workflows/e2e-next-dev.yml
name: E2E Test for Next.js Dev
name: E2E Test for Next.js Prod

on:
workflow_call:

jobs:
e2e-next:
e2e-next-prod:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
Expand Down Expand Up @@ -52,14 +51,3 @@ jobs:
npx wait-on tcp:3000 &&
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
lsof -ti tcp:3000,3001,3002 | xargs kill

- name: E2E Test for Next.js Dev
if: steps.check-ci.outcome == 'success'
run: |
pnpm run app:next:dev > /dev/null 2>&1 &
sleep 1 &&
npx wait-on tcp:3001 &&
npx wait-on tcp:3002 &&
npx wait-on tcp:3000 &&
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
lsof -ti tcp:3000,3001,3002 | xargs kill
2 changes: 1 addition & 1 deletion .github/workflows/e2e-router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:

- name: E2E Test for Runtime Demo
if: steps.check-ci.outcome == 'success'
run: npx kill-port --port 2000,2001,2002,2003,2004,2200,2100 && pnpm run app:router:dev & echo "done" && sleep 20 && npx nx run-many --target=test:e2e --projects=router-host-2000 --parallel=1 && lsof -ti tcp:2000,2001,2002,2003,2004,2200,2100 | xargs kill
run: npx kill-port --port 2000,2001,2002,2003,2004,2200,2100 && pnpm run app:router:dev & echo "done" && sleep 30 && npx nx run-many --target=test:e2e --projects=router-host-2000 --parallel=1 && lsof -ti tcp:2000,2001,2002,2003,2004,2200,2100 | xargs kill
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
/tmp
/out-tsc
/build
**/@mf-types
**/@mf-types/**
/docs
/.nx
# dependencies
Expand Down Expand Up @@ -51,17 +49,17 @@ migrations.json
packages/**/dist
apps/**/dist

**/@mf-types
**/@mf-types/**
**/cypress/downloads

# test cases
!packages/enhanced/test/configCases/**/**/node_modules
packages/enhanced/test/js
.ignored
**/.mf
**/.mf/**

/apps/manifest-demo/**/@mf-types/
/apps/manifest-demo/webpack-host/@mf-types/
/apps/manifest-demo/3008-webpack-host/@mf-types/

# dts test cases
**/dist-test
**/dist-test/**
Expand Down
10 changes: 6 additions & 4 deletions apps/3000-home/cypress/e2e/app.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ describe('3000-home/', () => {
it('should display welcome message', () => {
getH1().contains('This is SPA combined');
});
it('Api endpoint works', () => {
const urls = ['/api/test'];
urls.forEach((url) => {
cy.request(url); // This makes a GET request, not a full page visit
});

describe('API endpoint should return json', () => {
it('Query Endpoint', () => {
cy.request('/api/test').then((response) => {
expect(response.headers['content-type']).to.include('application/json');
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion apps/3000-home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"devDependencies": {
"@module-federation/nextjs-mf": "workspace:*",
"@module-federation/utilities": "workspace:*"
"@module-federation/utilities": "workspace:*",
"@module-federation/runtime": "workspace:*"
},
"scripts": {
"start": "next start",
Expand Down
2 changes: 2 additions & 0 deletions apps/3000-home/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';
import { useState } from 'react';
import { init } from '@module-federation/runtime';
console.log('logging init', typeof init);
import App from 'next/app';
import { Layout, version, ConfigProvider } from 'antd';
import { StyleProvider } from '@ant-design/cssinjs';
Expand Down
1 change: 0 additions & 1 deletion apps/manifest-demo/webpack-host/src/index.ts

This file was deleted.

51 changes: 51 additions & 0 deletions apps/manifest-demo/webpack-host/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// import('./bootstrap');
import React, { StrictMode, lazy } from 'react';
import { init } from '@module-federation/runtime';
import * as ReactDOM from 'react-dom/client';
import {
createBrowserRouter,
createRoutesFromElements,
Route,
RouterProvider,
} from 'react-router-dom';
import App from './App';
import Root from './Root';
import customPlugin from './runtimePlugin';

const router = createBrowserRouter([
{
path: '/',
element: <Root />,
children: [
{
path: 'basic',
element: <App />,
},
{
path: 'preload',
Component: lazy(() => import('./Preload')),
},
],
},
]);

init({
name: 'manifest_host',
remotes: [
{
name: 'rspack_provider',
alias: 'dynamic-remote',
entry: 'http://localhost:3010/mf-manifest.json',
},
],
plugins: [customPlugin()],
});

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
);
root.render(
<StrictMode>
<RouterProvider router={router} />
</StrictMode>,
);
6 changes: 5 additions & 1 deletion apps/manifest-demo/webpack-host/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => {
'react-dom': {},
'react-dom/': {},
},
embedRuntime: true,
runtimePlugins: [path.join(__dirname, './runtimePlugin.ts')],
}),
);
Expand All @@ -46,6 +47,7 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => {
if (config.devServer) {
config.devServer.client.overlay = false;
}
config.entry = './src/index.tsx';
//Temporary workaround - https://github.com/nrwl/nx/issues/16983
config.experiments = { outputModule: false };

Expand All @@ -54,8 +56,10 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => {
scriptType: 'text/javascript',
};
config.optimization = {
runtimeChunk: false,
runtimeChunk: 'single',
minimize: false,
moduleIds: 'named',
chunkIds: 'named',
};
config.output.publicPath = 'http://localhost:3013/';
return config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './compiled-types/Image';
export { default } from './compiled-types/Image';
export * from './compiled-types/src/components/Image';
export { default } from './compiled-types/src/components/Image';

This file was deleted.

1 change: 1 addition & 0 deletions apps/modernjs-ssr/host/cypress/downloads/downloads.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cr24
25 changes: 9 additions & 16 deletions apps/runtime-demo/3005-runtime-host/src/Remote1.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import React, { Suspense, lazy } from 'react';
import { loadRemote } from '@module-federation/runtime';

export const WebpackSvgRemote = function () {
const WebpackSvgRemote = lazy(() => import('remote1/WebpackSvg'));
return (
<Suspense fallback="loading WebpackSvgRemote">
<WebpackSvgRemote />
</Suspense>
);
};
export const WebpackSvgRemote = React.lazy(async () => {
const WebpackSvgRemote = await loadRemote('remote1/WebpackSvg');
return WebpackSvgRemote;
});

export const WebpackPngRemote = function () {
const WebpackPngRemote = lazy(() => import('remote1/WebpackPng'));
return (
<Suspense fallback="loading WebpackPngRemote">
<WebpackPngRemote />
</Suspense>
);
};
export const WebpackPngRemote = React.lazy(async () => {
const WebpackPngRemote = await loadRemote('remote1/WebpackPng');
return WebpackPngRemote;
});

function Remote1() {
return (
Expand Down
6 changes: 2 additions & 4 deletions apps/runtime-demo/3005-runtime-host/src/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Suspense, lazy } from 'react';
import TestRemoteHook from './test-remote-hook';
// import TestRemoteHook from './test-remote-hook';
import LocalBtn from './components/ButtonOldAnt';
import WebpackPng from './webpack.png';
import WebpackSvg from './webpack.svg';
Expand Down Expand Up @@ -31,9 +31,7 @@ const Root = () => (
</div>
</div>
</td>
<td>
<TestRemoteHook />
</td>
<td>{/* <TestRemoteHook /> */}</td>
</tr>
<tr>
<td>✅</td>
Expand Down
5 changes: 5 additions & 0 deletions apps/runtime-demo/3005-runtime-host/src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ init({
alias: 'dynamic-remote',
entry: 'http://127.0.0.1:3007/mf-manifest.json',
},
{
name: 'runtime_remote1',
alias: 'remote1',
entry: 'http://127.0.0.1:3006/mf-manifest.json',
},
],
});

Expand Down
2 changes: 1 addition & 1 deletion apps/runtime-demo/3005-runtime-host/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import customPlugin from './runtimePlugin';

registerGlobalPlugins([customPlugin()]);

import('./bootstrap');
require('./bootstrap');
Loading
Loading