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

feat: Unify Federation with ModernJS & Byte Infra team #1268

Merged
merged 272 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
272 commits
Select commit Hold shift + click to select a range
10fb1ae
Merge remote-tracking branch 'origin/improve_auto_public_path' into i…
ScriptedAlchemy Sep 7, 2023
c374178
chore: fix webpack build config of host
ScriptedAlchemy Sep 7, 2023
b654643
refactor: Improved readability and documentation of httpVmStrategy fu…
ScriptedAlchemy Sep 7, 2023
e5535b5
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 7, 2023
9611138
Merge pull request #1312 from module-federation/improve_auto_public_path
ScriptedAlchemy Sep 7, 2023
bdf6d03
refactor: refactor DelegateModulesPlugin.ts
ScriptedAlchemy Sep 7, 2023
7d192b3
Merge branch 'main' into node_auto_public_path
ScriptedAlchemy Sep 8, 2023
90fff24
chore(node): add jest environment and webpack global to ESLint config…
ScriptedAlchemy Sep 8, 2023
df8bb79
feat(utilities): update DelegateModulesPlugin and tests (#node_auto_p…
ScriptedAlchemy Sep 8, 2023
a83f67c
chore(node): remove unused importMetaName and update parseRemotes tes…
ScriptedAlchemy Sep 8, 2023
ee9e918
chore update locks
ScriptedAlchemy Sep 8, 2023
5064f18
chore(node-remote): enable disk writes in development mode #node_auto…
ScriptedAlchemy Sep 8, 2023
760703f
Merge branch 'main' into node_auto_public_path
ScriptedAlchemy Sep 8, 2023
b12c984
feat: add auto public path support for remote modules (node_auto_publ…
ScriptedAlchemy Sep 8, 2023
65989da
feat(node): auto set public path and improve chunk loading strategy #…
ScriptedAlchemy Sep 8, 2023
454dbd4
Merge branch 'node-sync-bytedance' into node_auto_public_path
ScriptedAlchemy Sep 8, 2023
3a105e7
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 8, 2023
d4e2be8
style(node): disable eslint for getDependenciesOfChunk function in Ch…
ScriptedAlchemy Sep 8, 2023
b60967b
refactor(node): destructure chunkHasJs from jsModulePlugin for cleane…
ScriptedAlchemy Sep 8, 2023
f9787a9
feat(node): remove unused import from DynamicFilesystemRuntimeModule
ScriptedAlchemy Sep 8, 2023
d420ad9
fix(node): use ES6 imports and override method in FederationModuleInf…
ScriptedAlchemy Sep 8, 2023
0c06ce9
remove usage of createDelegatedModule from nextjs-mf (#node-sync-byt…
ScriptedAlchemy Sep 8, 2023
12559f4
lock file
ScriptedAlchemy Sep 8, 2023
0cd1626
Merge branch 'node-sync-bytedance' into node_auto_public_path
ScriptedAlchemy Sep 8, 2023
967782d
lock file
ScriptedAlchemy Sep 8, 2023
0a5df1e
chore(deps): update dependency @types/express to v4.17.17
ScriptedAlchemy Sep 8, 2023
1f3f197
chore(deps): update dependency @vitest/coverage-c8 to v0.33.0
ScriptedAlchemy Sep 8, 2023
fa5184b
Merge pull request #1326 from module-federation/renovate/express-4.x
ScriptedAlchemy Sep 8, 2023
25a4f9a
chore(deps): update dependency @vitest/ui to v0.34.3
ScriptedAlchemy Sep 8, 2023
b35731d
Merge pull request #1327 from module-federation/renovate/vitest-cover…
ScriptedAlchemy Sep 8, 2023
993be1c
Merge pull request #1330 from module-federation/renovate/vitest-ui-0.x
ScriptedAlchemy Sep 8, 2023
87d73cc
fix(deps): pin dependency lodash.get to 4.4.2
ScriptedAlchemy Sep 8, 2023
b3a9d1b
chore(deps): update dependency @vitest/coverage-istanbul to v0.34.3
ScriptedAlchemy Sep 8, 2023
cab7523
chore(deps): update dependency esbuild to v0.19.2
ScriptedAlchemy Sep 8, 2023
df3e814
Merge pull request #1331 from module-federation/renovate/esbuild-0.x
ScriptedAlchemy Sep 8, 2023
f1265e5
Merge pull request #1329 from module-federation/renovate/lodash-monorepo
ScriptedAlchemy Sep 8, 2023
71cd67c
Merge pull request #1328 from module-federation/renovate/vitest-cover…
ScriptedAlchemy Sep 8, 2023
4e4431b
lock file
ScriptedAlchemy Sep 8, 2023
905bf82
fix(deps): pin dependencies
ScriptedAlchemy Sep 8, 2023
eacb130
Merge pull request #1325 from module-federation/renovate/pin-dependen…
ScriptedAlchemy Sep 8, 2023
05f9284
Simplified the logic for adding AutoPublicPathRuntimeModule to the co…
ScriptedAlchemy Sep 8, 2023
7df7bb2
lock file
ScriptedAlchemy Sep 8, 2023
6b3355c
Merge pull request #1342 from module-federation/improve_auto_public_p…
ScriptedAlchemy Sep 8, 2023
e7563b7
chore(deps): update dependency @vitest/ui to v0.34.4
ScriptedAlchemy Sep 9, 2023
a5c3dcb
Merge pull request #1350 from module-federation/renovate/vitest-ui-0.x
ScriptedAlchemy Sep 9, 2023
275a781
chore(deps): update dependency @vitest/coverage-istanbul to v0.34.4
ScriptedAlchemy Sep 9, 2023
4441f6e
Merge pull request #1349 from module-federation/renovate/vitest-cover…
ScriptedAlchemy Sep 9, 2023
f5b620c
Update default-delegate.ts
ScriptedAlchemy Sep 12, 2023
1bcd266
Merge pull request #1307 from module-federation/node_auto_public_path
ScriptedAlchemy Sep 12, 2023
5bea5b4
chore(node): enhance code readability in FederationModuleInfoRuntimeM…
ScriptedAlchemy Sep 12, 2023
ca33d98
feat(NodeFederationPlugin): assign remoteContainerRegistry to importM…
ScriptedAlchemy Sep 12, 2023
061285e
feat(node): enhance error handling and remote container registry in R…
ScriptedAlchemy Sep 12, 2023
5ac0e4b
lock files
ScriptedAlchemy Sep 12, 2023
5eb2092
feat(node-remote): Improve module federation runtime compatibility
ScriptedAlchemy Sep 13, 2023
63331ae
chore: Demo local remote
ScriptedAlchemy Sep 13, 2023
d311170
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 13, 2023
e84066c
update lock
ScriptedAlchemy Sep 13, 2023
5348111
Merge branch 'node-sync-bytedance' into local_remotes
ScriptedAlchemy Sep 13, 2023
93bf799
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 13, 2023
63b2a51
Merge branch 'node-sync-bytedance' into local_remotes
ScriptedAlchemy Sep 13, 2023
74197fa
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 13, 2023
b373a77
Merge branch 'node-sync-bytedance' into local_remotes
ScriptedAlchemy Sep 13, 2023
8c4acdc
chore: updae locks
ScriptedAlchemy Sep 13, 2023
459ff60
Merge remote-tracking branch 'origin/local_remotes' into local_remotes
ScriptedAlchemy Sep 13, 2023
2429fc8
chore: lock files
ScriptedAlchemy Sep 13, 2023
313640a
Merge branch 'main' into local_remotes
ScriptedAlchemy Sep 13, 2023
221f61e
chore: node local remote example
ScriptedAlchemy Sep 13, 2023
366e6df
chore: node local remote example
ScriptedAlchemy Sep 13, 2023
5c30128
chore: node local remote example
ScriptedAlchemy Sep 13, 2023
5c6107c
chore: node local remote example
ScriptedAlchemy Sep 13, 2023
8872327
Merge branch 'local_remote_app' into local_remotes
ScriptedAlchemy Sep 13, 2023
ca5fa50
chore: increase parallelism of nx
ScriptedAlchemy Sep 13, 2023
4d1528b
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 13, 2023
b5114c7
Merge branch 'node-sync-bytedance' into local_remotes
ScriptedAlchemy Sep 13, 2023
8f5de2f
Merge pull request #1375 from module-federation/local_remotes
ScriptedAlchemy Sep 13, 2023
fbe19bc
feat: remove old loadScript hack
ScriptedAlchemy Sep 13, 2023
bc8a541
chore: fix examples
ScriptedAlchemy Sep 13, 2023
0e2aee0
Merge branch 'main' into local_remotes
ScriptedAlchemy Sep 13, 2023
d0f5a52
Merge branch 'node-sync-bytedance' into local_remotes
ScriptedAlchemy Sep 13, 2023
564ed1f
chore: fix examples
ScriptedAlchemy Sep 13, 2023
07a439c
Merge pull request #1384 from module-federation/local_remotes
ScriptedAlchemy Sep 13, 2023
df7f423
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 13, 2023
5704c8d
refactor: break public path into own function
ScriptedAlchemy Sep 13, 2023
9f7e0fe
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 14, 2023
713ed91
chore(utils): release version 3.0.2-beta.0
ScriptedAlchemy Sep 14, 2023
2767191
fix: import utils manually
ScriptedAlchemy Sep 14, 2023
33b5ce7
chore(utils): release version 3.0.2
ScriptedAlchemy Sep 14, 2023
6e1003d
chore(node): release version 2.0.2-beta.0
ScriptedAlchemy Sep 14, 2023
d53b586
feat: support vmok conventions
ScriptedAlchemy Sep 14, 2023
0501da8
feat: support vmok conventions
ScriptedAlchemy Sep 14, 2023
1bd9dba
chore(node): release version 2.0.2-beta.1
ScriptedAlchemy Sep 14, 2023
a08fcab
fix: ensure custom FS works with target: node or async node preset
ScriptedAlchemy Sep 14, 2023
65f17b1
fix: Auto Public Path, detect multiple output targets
ScriptedAlchemy Sep 14, 2023
98cd8fd
Merge branch 'node-sync-bytedance' into vmok/public-path
ScriptedAlchemy Sep 14, 2023
b4e633b
fix: simplify template
ScriptedAlchemy Sep 14, 2023
c956e52
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 15, 2023
1e9bfb9
chore(node): release version 2.0.2-beta.2
ScriptedAlchemy Sep 15, 2023
ef74cbc
Merge pull request #1387 from module-federation/vmok/public-path
ScriptedAlchemy Sep 15, 2023
c11dc96
Merge remote-tracking branch 'origin/node-sync-bytedance' into node-s…
ScriptedAlchemy Sep 15, 2023
f22dc25
fix: search registry for both ident and unique name
ScriptedAlchemy Sep 15, 2023
37a236e
sync with byte
ScriptedAlchemy Sep 19, 2023
d0b6852
rename files, remove olds
ScriptedAlchemy Sep 19, 2023
3c58780
feat: Static fallback to non auto public path
ScriptedAlchemy Sep 20, 2023
9d0fcdd
feat: create and expose AutomaticPublicPathPlugin.ts
ScriptedAlchemy Sep 20, 2023
aafa76e
refactor: server apply
ScriptedAlchemy Sep 20, 2023
1549a37
refactor: reload local share scope into global memory
ScriptedAlchemy Sep 20, 2023
aec9506
refactor: reload local share scope into global memory
ScriptedAlchemy Sep 21, 2023
e89f2fe
WIP next/node stuff
ScriptedAlchemy Sep 21, 2023
0a2c1af
eject webpack
ScriptedAlchemy Sep 21, 2023
019694e
feat: improved async init
ScriptedAlchemy Sep 22, 2023
08aa0fa
feat: improved async init
ScriptedAlchemy Sep 22, 2023
845798c
Merge branch 'main' into next_byte_implementation
ScriptedAlchemy Sep 22, 2023
40e3576
add todo
ScriptedAlchemy Sep 22, 2023
9048da4
Merge branch 'main' into next_byte_implementation
ScriptedAlchemy Sep 22, 2023
6f4040e
Merge branch 'main' into next_byte_implementation
ScriptedAlchemy Sep 22, 2023
9b8f652
fix: ts in template string
ScriptedAlchemy Sep 22, 2023
de74b75
Merge branch 'main' into next_byte_implementation
ScriptedAlchemy Sep 22, 2023
0edbbea
fix: ts in template string
ScriptedAlchemy Sep 23, 2023
37e790a
fix: ts in template string
ScriptedAlchemy Sep 23, 2023
579b341
fix: ts in template string
ScriptedAlchemy Sep 23, 2023
0a0d03d
fix: ts in template string
ScriptedAlchemy Sep 23, 2023
d506b49
fix: TS imports to webpack
ScriptedAlchemy Sep 23, 2023
e021d66
feat: Use enhanced Federation Plugin
ScriptedAlchemy Sep 23, 2023
b0f7b56
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 23, 2023
126032e
style: prettier lint
ScriptedAlchemy Sep 23, 2023
ed5d992
Merge branch 'node-sync-bytedance' into next_byte_implementation
ScriptedAlchemy Sep 23, 2023
974deb3
style: prettier lint
ScriptedAlchemy Sep 23, 2023
cc2e53f
fix: bad impleentation during federation port
ScriptedAlchemy Sep 23, 2023
c370101
chore: types
ScriptedAlchemy Sep 23, 2023
49b8e3a
re-enable remote imports
ScriptedAlchemy Sep 24, 2023
73352fa
restore normal operations
ScriptedAlchemy Sep 24, 2023
992d298
fix: package data
ScriptedAlchemy Sep 24, 2023
9ed3441
build: build dependencies
ScriptedAlchemy Sep 24, 2023
92130e2
export contaainr plugins
ScriptedAlchemy Sep 24, 2023
b2fc5a2
chore: temp container inversion plugin
ScriptedAlchemy Sep 24, 2023
22098c6
chore: update Ts module type to Node16
ScriptedAlchemy Sep 24, 2023
718c3fc
feat: remove custom jsonp runtime patching
ScriptedAlchemy Sep 24, 2023
52ad258
feat: container inversion module injection
ScriptedAlchemy Sep 24, 2023
2dc23fc
build: update scripts and tsconfig
ScriptedAlchemy Sep 25, 2023
39e37b6
style: prettier
ScriptedAlchemy Sep 25, 2023
0604461
feat: additional plugin exports
ScriptedAlchemy Sep 25, 2023
f40c538
fix: change exports for module info runtime
ScriptedAlchemy Sep 25, 2023
17640dc
feat(enhanced): async boundary plugin
ScriptedAlchemy Sep 25, 2023
66ac81d
feat(enhanced): Embedded Container Plugin
ScriptedAlchemy Sep 25, 2023
4d80a2c
refactor(ContainerInversion): apply embed and async boundary plugins
ScriptedAlchemy Sep 25, 2023
427e237
refactor: remote attach runtime module.
ScriptedAlchemy Sep 25, 2023
0633e3d
remove early return bailout from eager shared module plugin
ScriptedAlchemy Sep 25, 2023
f6e3720
refactor: apply plugin partials
ScriptedAlchemy Sep 25, 2023
b8c9859
feat: rewrite next federation vanity plugin
ScriptedAlchemy Sep 25, 2023
bce3a31
refactor: remove comments and old ts stuff
ScriptedAlchemy Sep 25, 2023
858d103
refactor: remove duplicate plugins and use enhanced
ScriptedAlchemy Sep 25, 2023
2f83d23
silence logs on package patch
ScriptedAlchemy Sep 25, 2023
49b4a57
fix(enhanced): module info duplication
ScriptedAlchemy Sep 25, 2023
e7ac801
fix: add missing serialize method on RemoteModule
ScriptedAlchemy Sep 25, 2023
9bab3de
fix: reduce noise on async boundary plugin
ScriptedAlchemy Sep 25, 2023
90caa8d
fix: module order of inverted container runtime
ScriptedAlchemy Sep 25, 2023
c370ed5
fix: remove logger in filesystem
ScriptedAlchemy Sep 25, 2023
0aeec43
chore: cleanup code
ScriptedAlchemy Sep 25, 2023
415eda1
demo code
ScriptedAlchemy Sep 25, 2023
c748caa
fixes
ScriptedAlchemy Sep 25, 2023
7b12c96
comment out bugs
ScriptedAlchemy Sep 25, 2023
8eb422d
fix: TS imports, missing module methods
ScriptedAlchemy Sep 25, 2023
b5ceb3f
Merge branch 'node-sync-bytedance' into next_byte_implementation
ScriptedAlchemy Sep 25, 2023
d498d01
chore: add MFP types
ScriptedAlchemy Sep 26, 2023
99bd90b
chore: add MFP types
ScriptedAlchemy Sep 26, 2023
ed89420
chore: eslint stuff
ScriptedAlchemy Sep 26, 2023
f6e3e7f
fix: ignore TS issues in async plugin
ScriptedAlchemy Sep 26, 2023
0296443
refactor: apply module info plugin manually
ScriptedAlchemy Sep 26, 2023
3afe08a
refactor: remove hooks from delegate module plugin
ScriptedAlchemy Sep 26, 2023
713bcb4
style: lint
ScriptedAlchemy Sep 26, 2023
eb5a0c6
style: lint
ScriptedAlchemy Sep 26, 2023
0079495
style: lint
ScriptedAlchemy Sep 26, 2023
649bfc3
style: lint
ScriptedAlchemy Sep 26, 2023
1ec5f0f
feat: use enhanced federation plugin
ScriptedAlchemy Sep 26, 2023
12ed54c
fix: export parseRemotes
ScriptedAlchemy Sep 26, 2023
ea4f105
fix: lint container module
ScriptedAlchemy Sep 26, 2023
5e584e6
feat: implement custom next vanity federation plugin
ScriptedAlchemy Sep 26, 2023
b69b70d
feat: improve options logic in node federation plugin
ScriptedAlchemy Sep 26, 2023
19b1afb
fix: add exported file
ScriptedAlchemy Sep 26, 2023
023dfaf
style: ts imports
ScriptedAlchemy Sep 26, 2023
075015a
style: ts imports
ScriptedAlchemy Sep 26, 2023
197d26f
style: ts imports
ScriptedAlchemy Sep 26, 2023
7764d1f
style: ts imports
ScriptedAlchemy Sep 26, 2023
1d0fdec
style: ts imports
ScriptedAlchemy Sep 26, 2023
9ecce7e
chore: update webpack TS sync logic
ScriptedAlchemy Sep 26, 2023
5493346
update postinstall
ScriptedAlchemy Sep 26, 2023
d605dc5
style: prettier
ScriptedAlchemy Sep 26, 2023
844c12f
prettier webpack types
ScriptedAlchemy Sep 26, 2023
1f020fe
Merge branch 'node-sync-bytedance' into next_byte_implementation
ScriptedAlchemy Sep 26, 2023
9c190d9
chore: update TS files
ScriptedAlchemy Sep 26, 2023
875038a
fix: add override to remoteModule
ScriptedAlchemy Sep 26, 2023
7b52c43
remaining stuff
ScriptedAlchemy Sep 26, 2023
5ae3548
linst issues
ScriptedAlchemy Sep 26, 2023
4db1f3d
remove tests
ScriptedAlchemy Sep 26, 2023
980fc7f
ignore typesciprt crap
ScriptedAlchemy Sep 26, 2023
c13ea37
enable nested imports
ScriptedAlchemy Sep 26, 2023
c110b7c
enable nested imports
ScriptedAlchemy Sep 26, 2023
aff0685
enable full demo imports
ScriptedAlchemy Sep 26, 2023
29c234c
feat: support lazy compilation
ScriptedAlchemy Sep 26, 2023
7f253f1
feat: prefer host modules for next and react
ScriptedAlchemy Sep 26, 2023
2bee364
Add TS modules for sample Next apps
RussellCanfield Sep 26, 2023
105c124
fix: remove hard coded share scope
ScriptedAlchemy Sep 26, 2023
f0d7671
fix: dont crash offline remotes
ScriptedAlchemy Sep 26, 2023
635c035
Merge remote-tracking branch 'origin/next_byte_implementation' into n…
ScriptedAlchemy Sep 26, 2023
12ff71c
chore: patching changes from next branch
ScriptedAlchemy Sep 26, 2023
e05d32f
fix: remote global share scope
ScriptedAlchemy Sep 27, 2023
d3aa2e7
Merge pull request #1433 from module-federation/next_byte_implementation
ScriptedAlchemy Sep 27, 2023
f95e23f
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 27, 2023
5b8eed3
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 27, 2023
d821562
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 27, 2023
1d65335
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 27, 2023
c8daa8c
chore: fix dep tracking
ScriptedAlchemy Sep 27, 2023
f4843ec
fix: resupport delegate modules
ScriptedAlchemy Sep 28, 2023
9b27e63
Merge pull request #1464 from module-federation/delegate_module_reimp…
ScriptedAlchemy Sep 28, 2023
53ad509
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Sep 28, 2023
40b8c28
fix: remove logging on DFS
ScriptedAlchemy Sep 28, 2023
347e4c9
fix: legacy scope duplication on recreation
ScriptedAlchemy Sep 28, 2023
ac0efa3
fix: improve backward compat __remote_scope__ global
ScriptedAlchemy Sep 28, 2023
6e7974c
fix: Ts import error
ScriptedAlchemy Sep 28, 2023
1c5c6a8
fix: server sharing
ScriptedAlchemy Sep 28, 2023
d14324a
fix: use ES5 for renderStartup of entrypoint
ScriptedAlchemy Sep 28, 2023
00227ca
feat: AsyncBoundaryPlugin
ScriptedAlchemy Sep 28, 2023
e7fada2
fix: broken versioning issues in consumes
ScriptedAlchemy Sep 28, 2023
8eea1a8
fix: improve logic in runtime module info proxy
ScriptedAlchemy Sep 28, 2023
8a1800d
refactor: use noop to include shared next modules
ScriptedAlchemy Sep 28, 2023
c36ffc4
refactor: import async Boundary plugin (enhanced)
ScriptedAlchemy Sep 28, 2023
a50dae8
fix: add styled-jsx to internal share
ScriptedAlchemy Sep 28, 2023
f4b0386
feat: share next/image
ScriptedAlchemy Sep 28, 2023
d86dcde
fix: improve image loader public path calc
ScriptedAlchemy Sep 28, 2023
6098fee
fix: enable path fixes again
ScriptedAlchemy Sep 28, 2023
2f9e14b
fix: enable path fixes
ScriptedAlchemy Sep 28, 2023
3436892
fixL remove duplicate next/image share key
ScriptedAlchemy Sep 28, 2023
a3eb553
feat: checkInvalidContext as tapable hook
ScriptedAlchemy Sep 28, 2023
ae890d5
fix: ensure sharing of react/jsx runtime and dev runtime
ScriptedAlchemy Sep 28, 2023
0a07481
fix: typescript issues
ScriptedAlchemy Sep 29, 2023
b20ded1
convert DFS to Typescript
ScriptedAlchemy Sep 29, 2023
72d5554
chore: fix builds
ScriptedAlchemy Sep 29, 2023
8f8481b
Merge branch 'node-sync-bytedance' into tappable_async_boundary
ScriptedAlchemy Sep 29, 2023
1e325a6
fix: set requiredVersion to false on utils
ScriptedAlchemy Sep 29, 2023
99b79b5
style:lint source
ScriptedAlchemy Sep 29, 2023
0de03e4
Merge pull request #1470 from module-federation/tappable_async_boundary
ScriptedAlchemy Sep 29, 2023
c1db325
fix: stats plugin updates
ScriptedAlchemy Sep 29, 2023
99f733b
fix: hot reloading system
ScriptedAlchemy Sep 29, 2023
c9df545
fix: chunk flushing
ScriptedAlchemy Sep 29, 2023
6e16fa1
Change swc interop to false so it defaults to swc interop helper (imp…
RussellCanfield Sep 30, 2023
180cb8f
Fix remaining import requires
RussellCanfield Sep 30, 2023
37458b7
Merge pull request #1474 from module-federation/rcanfield-node-sync-b…
ScriptedAlchemy Oct 2, 2023
1a436c4
chore: add release tasks to enhanced
ScriptedAlchemy Oct 3, 2023
5e06962
Merge branch 'main' into node-sync-bytedance
ScriptedAlchemy Oct 3, 2023
ef8e403
chore: set basebranch
ScriptedAlchemy Oct 3, 2023
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
27 changes: 27 additions & 0 deletions packages/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ revalidate().then((shouldReload) => {
});
```

### Overrideing default http chunk fetch

```js
const chunkFetcher = globalThis.webpackChunkLoad || globalThis.fetch || fetchPolyfill;
// then it will pass one argument to the function, the url to fetch

chunkFetcher(url)
.then((res) => res.text())
.then((text) => {
// do something with the text
});
```

if you want to use your own custom fetch, or add fetch headers, either in the entrypoint of webpack or outside
of webpack scope, like in express server- you can override the default chunk fetcher by setting the globalThis.webpackChunkLoad variable.

```js
globalThis.webpackChunkLoad = async (url) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may no longer be appliciable, will have to check

const res = await fetch(url, {
headers: {
'x-custom-header': 'custom-header-value',
},
});
return res.text();
};
```

## 🔑 License

- MIT @[ScriptedAlchemy](https://github.com/ScriptedAlchemy)
Expand Down
82 changes: 52 additions & 30 deletions packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Chunk, Compiler } from 'webpack';
import type { Chunk, Compiler, Compilation, ChunkGraph } from 'webpack';
import type { ModuleFederationPluginOptions } from '../types';
import RuntimeGlobals from 'webpack/lib/RuntimeGlobals';
import StartupChunkDependenciesPlugin from 'webpack/lib/runtime/StartupChunkDependenciesPlugin';
import ChunkLoadingRuntimeModule from './LoadFileChunkLoadingRuntimeModule';
import FederationModuleInfoRuntimeModule from './FederationModuleInfoRuntimeModule';

interface CommonJsChunkLoadingOptions extends ModuleFederationPluginOptions {
baseURI: Compiler['options']['output']['publicPath'];
Expand Down Expand Up @@ -34,7 +35,7 @@ class CommonJsChunkLoadingPlugin {

compiler.hooks.thisCompilation.tap(
'CommonJsChunkLoadingPlugin',
(compilation) => {
(compilation: Compilation) => {
// Always enabled
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isEnabledForChunk = (_: Chunk) => true;
Expand All @@ -44,67 +45,88 @@ class CommonJsChunkLoadingPlugin {
if (onceForChunkSet.has(chunk)) return;

onceForChunkSet.add(chunk);

if (!isEnabledForChunk(chunk)) return;

if (!isEnabledForChunk(chunk)) {
return;
}
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
set.add(RuntimeGlobals.hasOwnProperty);

set.add(RuntimeGlobals.publicPath);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes import.meta which breaks node auto path

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2heal1 I think it's this which breaks other pr where public path is auto.

compilation.addRuntimeModule(
chunk,
new ChunkLoadingRuntimeModule(set, this.options, {
webpack: compiler.webpack,
})
);
};

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.ensureChunkHandlers)
.tap('CommonJsChunkLoadingPlugin', handler);

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
.tap('CommonJsChunkLoadingPlugin', handler);

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.hmrDownloadManifest)
.tap('CommonJsChunkLoadingPlugin', handler);

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.baseURI)
.tap('CommonJsChunkLoadingPlugin', handler);

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.externalInstallChunk)
.tap('CommonJsChunkLoadingPlugin', handler);

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.onChunksLoaded)
.tap('CommonJsChunkLoadingPlugin', handler);

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.ensureChunkHandlers)
.tap('CommonJsChunkLoadingPlugin', (chunk, set) => {
if (!isEnabledForChunk(chunk)) return;
set.add(RuntimeGlobals.getChunkScriptFilename);
});

.tap(
'CommonJsChunkLoadingPlugin',
(chunk: Chunk, set: Set<string>) => {
if (!isEnabledForChunk(chunk)) {
return;
}
set.add(RuntimeGlobals.getChunkScriptFilename);
}
);
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
.tap('CommonJsChunkLoadingPlugin', (chunk, set) => {
if (!isEnabledForChunk(chunk)) return;
set.add(RuntimeGlobals.getChunkUpdateScriptFilename);
set.add(RuntimeGlobals.moduleCache);
set.add(RuntimeGlobals.hmrModuleData);
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
});

.tap(
'CommonJsChunkLoadingPlugin',
(chunk: Chunk, set: Set<string>) => {
if (!isEnabledForChunk(chunk)) {
return;
}
set.add(RuntimeGlobals.getChunkUpdateScriptFilename);
set.add(RuntimeGlobals.moduleCache);
set.add(RuntimeGlobals.hmrModuleData);
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
}
);
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.hmrDownloadManifest)
.tap('CommonJsChunkLoadingPlugin', (chunk, set) => {
if (!isEnabledForChunk(chunk)) return;
set.add(RuntimeGlobals.getUpdateManifestFilename);
});
.tap(
'CommonJsChunkLoadingPlugin',
(chunk: Chunk, set: Set<string>) => {
if (!isEnabledForChunk(chunk)) {
return;
}
set.add(RuntimeGlobals.getUpdateManifestFilename);
}
);

compilation.hooks.additionalTreeRuntimeRequirements.tap(
'StartupChunkDependenciesPlugin',
(
chunk: Chunk,
set: Set<string>,
{ chunkGraph }: { chunkGraph: ChunkGraph }
) => {
compilation.addRuntimeModule(
chunk,
//@ts-ignore
new FederationModuleInfoRuntimeModule()
);
}
);
}
);
}
Expand Down
25 changes: 25 additions & 0 deletions packages/node/src/plugins/FederationModuleInfoRuntimeModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const { RuntimeGlobals } = require('webpack');
const { RuntimeModule } = require('webpack');
const { Template } = require('webpack');

class FederationModuleInfoRuntimeModule extends RuntimeModule {
constructor() {
super('federation module info runtime', RuntimeModule.STAGE_BASIC + 1);
}

/**
* @returns {string} runtime code
*/
// eslint-disable-next-line max-lines-per-function
generate() {
return Template.asString([
`${RuntimeGlobals.require}.federation = {`,
Template.indent([`cache: {},`, `remotes: {},`, `moduleInfo: {},`]),
`}`,
]);
}
}

export default FederationModuleInfoRuntimeModule;
16 changes: 6 additions & 10 deletions packages/node/src/plugins/StreamingTargetPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ class StreamingTargetPlugin {
}

apply(compiler: Compiler) {
if (compiler.options.target) {
console.warn(
`target should be set to false while using NodeSoftwareStreamRuntime plugin, actual target: ${compiler.options.target}`
);
console.info('Setting target to false');
compiler.options.target = false;
ScriptedAlchemy marked this conversation as resolved.
Show resolved Hide resolved
}

// When used with Next.js, context is needed to use Next.js webpack
const { webpack } = compiler;

// This will enable CommonJsChunkFormatPlugin
compiler.options.output.chunkFormat = 'commonjs';
// This will force async chunk loading
if (compiler.options.output.enabledLibraryTypes === undefined) {
compiler.options.output.enabledLibraryTypes = ['commonjs-module'];
} else {
compiler.options.output.enabledLibraryTypes.push('commonjs-module');
}

compiler.options.output.chunkLoading = 'async-node';

// Disable default config
Expand Down