@module-federation/node
Advanced tools
Comparing version 2.0.2-beta.2 to 2.0.2-beta.3
279
CHANGELOG.md
@@ -5,3 +5,3 @@ # Changelog | ||
## [2.0.2-beta.2](https://github.com/module-federation/nextjs-mf/compare/node-2.0.2-beta.1...node-2.0.2-beta.2) (2023-09-15) | ||
## [2.0.2-beta.3](https://github.com/module-federation/nextjs-mf/compare/node-2.0.2-beta.2...node-2.0.2-beta.3) (2023-10-03) | ||
@@ -11,40 +11,64 @@ | ||
* Auto Public Path, detect multiple output targets ([65f17b1](https://github.com/module-federation/nextjs-mf/commit/65f17b189f37e0ad9e72bb0bf04463e9c5455929)) | ||
* ensure custom FS works with target: node or async node preset ([a08fcab](https://github.com/module-federation/nextjs-mf/commit/a08fcab7dde903966d34be9dab0b34c8896948ca)) | ||
* add exported file ([19b1afb](https://github.com/module-federation/nextjs-mf/commit/19b1afbd58572897f36b16926f841e35d154c712)) | ||
* bad impleentation during federation port ([cc2e53f](https://github.com/module-federation/nextjs-mf/commit/cc2e53f0351fb94c9068223ad6b8d990a913ab53)) | ||
* chunk flushing ([c9df545](https://github.com/module-federation/nextjs-mf/commit/c9df5451c84e6458b392884492bf669bf7383d5c)) | ||
* dont crash offline remotes ([f0d7671](https://github.com/module-federation/nextjs-mf/commit/f0d7671569ac34f64017a303739b54880f5220e6)) | ||
* export parseRemotes ([12ed54c](https://github.com/module-federation/nextjs-mf/commit/12ed54c87ba539bc2a79cdee86058f0a2776653e)) | ||
* hot reloading system ([99f733b](https://github.com/module-federation/nextjs-mf/commit/99f733bbdbd727a99fbaaeab3f92f4b65fa568dd)) | ||
* remove logger in filesystem ([c370ed5](https://github.com/module-federation/nextjs-mf/commit/c370ed5fdc5fe3423703f29daa40a4227ac51cf2)) | ||
* remove logging on DFS ([40b8c28](https://github.com/module-federation/nextjs-mf/commit/40b8c28fac9c39fec8623415a36e487152c2ef34)) | ||
* search registry for both ident and unique name ([f22dc25](https://github.com/module-federation/nextjs-mf/commit/f22dc25e5a6374273b1bc51b0e101b57226c5906)) | ||
* simplify template ([b4e633b](https://github.com/module-federation/nextjs-mf/commit/b4e633b6624264456800bc7351c6d815430d42b5)) | ||
* stats plugin updates ([c1db325](https://github.com/module-federation/nextjs-mf/commit/c1db325d3311b2126964f4ad2ddbfa9d82a50674)) | ||
* ts in template string ([0edbbea](https://github.com/module-federation/nextjs-mf/commit/0edbbeaa42503237b88132252e29a34a79bade51)) | ||
* ts in template string ([9b8f652](https://github.com/module-federation/nextjs-mf/commit/9b8f652f96bf6f29d5fc238bb616e19187158a57)) | ||
### Features | ||
## [2.0.2-beta.1](https://github.com/module-federation/nextjs-mf/compare/node-2.0.2-beta.0...node-2.0.2-beta.1) (2023-09-14) | ||
* create and expose AutomaticPublicPathPlugin.ts ([9d0fcdd](https://github.com/module-federation/nextjs-mf/commit/9d0fcdd2e36fae971f2eec3269980baedf276b35)) | ||
* improve options logic in node federation plugin ([b69b70d](https://github.com/module-federation/nextjs-mf/commit/b69b70d200c63e3557089e8a0669fc43330c988c)) | ||
* improved async init ([bb19b07](https://github.com/module-federation/nextjs-mf/commit/bb19b07b5be1bbc28bd6b049ea7aea6510ad17a2)) | ||
* improved async init ([019694e](https://github.com/module-federation/nextjs-mf/commit/019694e55fe1f6bebfdab0701bf9087bf0034b8f)) | ||
* Static fallback to non auto public path ([3c58780](https://github.com/module-federation/nextjs-mf/commit/3c587809f1e936fba291eab3d7c790115be5102c)) | ||
* support vmok conventions ([0501da8](https://github.com/module-federation/nextjs-mf/commit/0501da86eaaab6ea79a3397c2c683086cc591309)) | ||
* support vmok conventions ([d53b586](https://github.com/module-federation/nextjs-mf/commit/d53b5867719eb7fff32bee2edd3255023d598f44)) | ||
* Use enhanced Federation Plugin ([e021d66](https://github.com/module-federation/nextjs-mf/commit/e021d6667996962f154137d164bed13f53a6a135)) | ||
## [2.0.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-2.0.1...node-2.0.2-beta.0) (2023-09-14) | ||
## [2.0.2-beta.2](https://github.com/module-federation/nextjs-mf/compare/node-2.0.2-beta.1...node-2.0.2-beta.2) (2023-09-15) | ||
### Bug Fixes | ||
* import utils manually ([2767191](https://github.com/module-federation/nextjs-mf/commit/2767191467d9d685704b747d42b5f170da233847)) | ||
* **node:** use ES6 imports and override method in FederationModuleInfoRuntimeModule (#bytedance) ([d420ad9](https://github.com/module-federation/nextjs-mf/commit/d420ad94b7515123254af45c61704abcc0971511)) | ||
* remove ensure remote runtime module ([d06c082](https://github.com/module-federation/nextjs-mf/commit/d06c0823435063dcd277897ab551cd3a9c996d3d)) | ||
- Auto Public Path, detect multiple output targets ([65f17b1](https://github.com/module-federation/nextjs-mf/commit/65f17b189f37e0ad9e72bb0bf04463e9c5455929)) | ||
- ensure custom FS works with target: node or async node preset ([a08fcab](https://github.com/module-federation/nextjs-mf/commit/a08fcab7dde903966d34be9dab0b34c8896948ca)) | ||
## [2.0.2-beta.1](https://github.com/module-federation/nextjs-mf/compare/node-2.0.2-beta.0...node-2.0.2-beta.1) (2023-09-14) | ||
### Features | ||
## [2.0.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-2.0.1...node-2.0.2-beta.0) (2023-09-14) | ||
* add auto public path support for remote modules (node_auto_public_path) ([b12c984](https://github.com/module-federation/nextjs-mf/commit/b12c9841aa55027cb7b77e768ff9c0b456120d51)) | ||
* Dynamic Filesystem ([#1274](https://github.com/module-federation/nextjs-mf/issues/1274)) ([2bec98a](https://github.com/module-federation/nextjs-mf/commit/2bec98a2472b44898a7f14ec6868a2368cfb6d82)) | ||
* FederationModuleInfo Runtime Module ([50a1a0c](https://github.com/module-federation/nextjs-mf/commit/50a1a0c7a37bbe42ab6f2f5559b411567fee0fe9)) | ||
* FederationModuleInfo Runtime Module ([7b09ef6](https://github.com/module-federation/nextjs-mf/commit/7b09ef6c0f4ee68a1b5caa5f021632059c522b8f)) | ||
* implement Bytedance Infra Node Plugin ([82e6801](https://github.com/module-federation/nextjs-mf/commit/82e680157bbad68fa93800a69149c4c28652cfed)) | ||
* implement Bytedance Infra Node Plugin ([97f283e](https://github.com/module-federation/nextjs-mf/commit/97f283e4746bf6f048ee27584adde5249c8e577c)) | ||
* native self forming node federation ([#1291](https://github.com/module-federation/nextjs-mf/issues/1291)) ([1dd5ed1](https://github.com/module-federation/nextjs-mf/commit/1dd5ed17c981e036336925e807203e94b58c36d6)) | ||
* **node-remote:** Improve module federation runtime compatibility ([5eb2092](https://github.com/module-federation/nextjs-mf/commit/5eb209249c44d525c12eff5739bf23a93db08e4f)) | ||
* **node:** auto set public path and improve chunk loading strategy #node_auto_public_path ([65989da](https://github.com/module-federation/nextjs-mf/commit/65989dab95ee2acee7ec9a5ab321921a278cd078)) | ||
* **node:** enhance error handling and remote container registry in RemotePublicPathRuntimeModule (#bytedance) ([061285e](https://github.com/module-federation/nextjs-mf/commit/061285e0b6210baa1dd502dc94fd57fd9a8af822)) | ||
* **NodeFederationPlugin:** assign remoteContainerRegistry to importMetaName ([ca33d98](https://github.com/module-federation/nextjs-mf/commit/ca33d98df63fdb8dac402b1cc0ec8bf95f9f1971)) | ||
* **node:** remove unused import from DynamicFilesystemRuntimeModule ([f9787a9](https://github.com/module-federation/nextjs-mf/commit/f9787a9a67da936679db388e5c66e012e7452d8a)) | ||
* remove old loadScript hack ([fbe19bc](https://github.com/module-federation/nextjs-mf/commit/fbe19bc76694c14b6a95c577669c2e8656ede1ba)) | ||
* **utilities:** update DelegateModulesPlugin and tests (#node_auto_public_path) ([df8bb79](https://github.com/module-federation/nextjs-mf/commit/df8bb791c3fedef299cb15960546ff5ad9c665ef)) | ||
### Bug Fixes | ||
- import utils manually ([2767191](https://github.com/module-federation/nextjs-mf/commit/2767191467d9d685704b747d42b5f170da233847)) | ||
- **node:** use ES6 imports and override method in FederationModuleInfoRuntimeModule (#bytedance) ([d420ad9](https://github.com/module-federation/nextjs-mf/commit/d420ad94b7515123254af45c61704abcc0971511)) | ||
- remove ensure remote runtime module ([d06c082](https://github.com/module-federation/nextjs-mf/commit/d06c0823435063dcd277897ab551cd3a9c996d3d)) | ||
### Features | ||
- add auto public path support for remote modules (node_auto_public_path) ([b12c984](https://github.com/module-federation/nextjs-mf/commit/b12c9841aa55027cb7b77e768ff9c0b456120d51)) | ||
- Dynamic Filesystem ([#1274](https://github.com/module-federation/nextjs-mf/issues/1274)) ([2bec98a](https://github.com/module-federation/nextjs-mf/commit/2bec98a2472b44898a7f14ec6868a2368cfb6d82)) | ||
- FederationModuleInfo Runtime Module ([50a1a0c](https://github.com/module-federation/nextjs-mf/commit/50a1a0c7a37bbe42ab6f2f5559b411567fee0fe9)) | ||
- FederationModuleInfo Runtime Module ([7b09ef6](https://github.com/module-federation/nextjs-mf/commit/7b09ef6c0f4ee68a1b5caa5f021632059c522b8f)) | ||
- implement Bytedance Infra Node Plugin ([82e6801](https://github.com/module-federation/nextjs-mf/commit/82e680157bbad68fa93800a69149c4c28652cfed)) | ||
- implement Bytedance Infra Node Plugin ([97f283e](https://github.com/module-federation/nextjs-mf/commit/97f283e4746bf6f048ee27584adde5249c8e577c)) | ||
- native self forming node federation ([#1291](https://github.com/module-federation/nextjs-mf/issues/1291)) ([1dd5ed1](https://github.com/module-federation/nextjs-mf/commit/1dd5ed17c981e036336925e807203e94b58c36d6)) | ||
- **node-remote:** Improve module federation runtime compatibility ([5eb2092](https://github.com/module-federation/nextjs-mf/commit/5eb209249c44d525c12eff5739bf23a93db08e4f)) | ||
- **node:** auto set public path and improve chunk loading strategy #node_auto_public_path ([65989da](https://github.com/module-federation/nextjs-mf/commit/65989dab95ee2acee7ec9a5ab321921a278cd078)) | ||
- **node:** enhance error handling and remote container registry in RemotePublicPathRuntimeModule (#bytedance) ([061285e](https://github.com/module-federation/nextjs-mf/commit/061285e0b6210baa1dd502dc94fd57fd9a8af822)) | ||
- **NodeFederationPlugin:** assign remoteContainerRegistry to importMetaName ([ca33d98](https://github.com/module-federation/nextjs-mf/commit/ca33d98df63fdb8dac402b1cc0ec8bf95f9f1971)) | ||
- **node:** remove unused import from DynamicFilesystemRuntimeModule ([f9787a9](https://github.com/module-federation/nextjs-mf/commit/f9787a9a67da936679db388e5c66e012e7452d8a)) | ||
- remove old loadScript hack ([fbe19bc](https://github.com/module-federation/nextjs-mf/commit/fbe19bc76694c14b6a95c577669c2e8656ede1ba)) | ||
- **utilities:** update DelegateModulesPlugin and tests (#node_auto_public_path) ([df8bb79](https://github.com/module-federation/nextjs-mf/commit/df8bb791c3fedef299cb15960546ff5ad9c665ef)) | ||
## [2.0.1](https://github.com/module-federation/nextjs-mf/compare/node-2.0.0...node-2.0.1) (2023-09-13) | ||
@@ -54,6 +78,5 @@ | ||
* `utils` updated to version `3.0.1` | ||
* `utils` updated to version `3.0.1` | ||
- `utils` updated to version `3.0.1` | ||
- `utils` updated to version `3.0.1` | ||
# [2.0.0](https://github.com/module-federation/nextjs-mf/compare/node-1.0.6...node-2.0.0) (2023-09-09) | ||
@@ -63,207 +86,213 @@ | ||
* `utils` updated to version `3.0.0` | ||
* `utils` updated to version `3.0.0` | ||
- `utils` updated to version `3.0.0` | ||
- `utils` updated to version `3.0.0` | ||
### Bug Fixes | ||
* workaround to self ref module error in prod ([#1205](https://github.com/module-federation/nextjs-mf/issues/1205)) ([1d88beb](https://github.com/module-federation/nextjs-mf/commit/1d88beb0da629f036e132573fee9f05494b1f540)) | ||
- workaround to self ref module error in prod ([#1205](https://github.com/module-federation/nextjs-mf/issues/1205)) ([1d88beb](https://github.com/module-federation/nextjs-mf/commit/1d88beb0da629f036e132573fee9f05494b1f540)) | ||
### Features | ||
* core package for module federation ([#1093](https://github.com/module-federation/nextjs-mf/issues/1093)) ([d460400](https://github.com/module-federation/nextjs-mf/commit/d46040053e9b627321b5fe8e05556c5bb727c238)), closes [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) [#835](https://github.com/module-federation/nextjs-mf/issues/835) [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) [#871](https://github.com/module-federation/nextjs-mf/issues/871) [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) [#872](https://github.com/module-federation/nextjs-mf/issues/872) [#875](https://github.com/module-federation/nextjs-mf/issues/875) [#884](https://github.com/module-federation/nextjs-mf/issues/884) [#887](https://github.com/module-federation/nextjs-mf/issues/887) [#893](https://github.com/module-federation/nextjs-mf/issues/893) [#885](https://github.com/module-federation/nextjs-mf/issues/885) [#899](https://github.com/module-federation/nextjs-mf/issues/899) [#904](https://github.com/module-federation/nextjs-mf/issues/904) [#932](https://github.com/module-federation/nextjs-mf/issues/932) [#936](https://github.com/module-federation/nextjs-mf/issues/936) [#959](https://github.com/module-federation/nextjs-mf/issues/959) [#960](https://github.com/module-federation/nextjs-mf/issues/960) [#969](https://github.com/module-federation/nextjs-mf/issues/969) [#971](https://github.com/module-federation/nextjs-mf/issues/971) [#1234](https://github.com/module-federation/nextjs-mf/issues/1234) [#1235](https://github.com/module-federation/nextjs-mf/issues/1235) | ||
- core package for module federation ([#1093](https://github.com/module-federation/nextjs-mf/issues/1093)) ([d460400](https://github.com/module-federation/nextjs-mf/commit/d46040053e9b627321b5fe8e05556c5bb727c238)), closes [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) [#835](https://github.com/module-federation/nextjs-mf/issues/835) [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) [#871](https://github.com/module-federation/nextjs-mf/issues/871) [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) [#872](https://github.com/module-federation/nextjs-mf/issues/872) [#875](https://github.com/module-federation/nextjs-mf/issues/875) [#884](https://github.com/module-federation/nextjs-mf/issues/884) [#887](https://github.com/module-federation/nextjs-mf/issues/887) [#893](https://github.com/module-federation/nextjs-mf/issues/893) [#885](https://github.com/module-federation/nextjs-mf/issues/885) [#899](https://github.com/module-federation/nextjs-mf/issues/899) [#904](https://github.com/module-federation/nextjs-mf/issues/904) [#932](https://github.com/module-federation/nextjs-mf/issues/932) [#936](https://github.com/module-federation/nextjs-mf/issues/936) [#959](https://github.com/module-federation/nextjs-mf/issues/959) [#960](https://github.com/module-federation/nextjs-mf/issues/960) [#969](https://github.com/module-federation/nextjs-mf/issues/969) [#971](https://github.com/module-federation/nextjs-mf/issues/971) [#1234](https://github.com/module-federation/nextjs-mf/issues/1234) [#1235](https://github.com/module-federation/nextjs-mf/issues/1235) | ||
### BREAKING CHANGES | ||
* automaticAsyncBoundary option has been removed | ||
- automaticAsyncBoundary option has been removed | ||
* fix: exclude specific pages from page map automatically | ||
- fix: exclude specific pages from page map automatically | ||
* refactor: conslidate codebase | ||
- refactor: conslidate codebase | ||
* fix: improve hot reload share recovery | ||
- fix: improve hot reload share recovery | ||
* refactor: remove server jsonp template | ||
- refactor: remove server jsonp template | ||
* chore: remove dead code from runtime modules | ||
- chore: remove dead code from runtime modules | ||
* fix: clean up jsonp getCustomJsonpCode | ||
- fix: clean up jsonp getCustomJsonpCode | ||
getting chunk loading global from compiler output options | ||
* feat: adding cleanInitArrays runtime helper | ||
- feat: adding cleanInitArrays runtime helper | ||
* chore: remove share scope hoist and module hoisting system | ||
- chore: remove share scope hoist and module hoisting system | ||
* chore: cleanup code | ||
- chore: cleanup code | ||
* chore: remove dead code from add module runtime plugin | ||
- chore: remove dead code from add module runtime plugin | ||
likely can remove whole plugin in future | ||
* chore: remove logs from delegate modules | ||
- chore: remove logs from delegate modules | ||
* chore: remove old utils | ||
- chore: remove old utils | ||
* fix: add warning on auto page stitch | ||
- fix: add warning on auto page stitch | ||
* fix: remove commented out code from InvertedContainerPlugin.ts | ||
- fix: remove commented out code from InvertedContainerPlugin.ts | ||
* chore: improve logging to see if its local load or remote load | ||
- chore: improve logging to see if its local load or remote load | ||
* chore: clean up old custom promises factories | ||
- chore: clean up old custom promises factories | ||
* fix: remove container proxy code | ||
- fix: remove container proxy code | ||
* fix: remove container proxy code | ||
* automaticAsyncBoundary option has been removed | ||
- fix: remove container proxy code | ||
- automaticAsyncBoundary option has been removed | ||
* fix: exclude specific pages from page map automatically | ||
- fix: exclude specific pages from page map automatically | ||
* refactor: conslidate codebase | ||
- refactor: conslidate codebase | ||
* fix: improve hot reload share recovery | ||
- fix: improve hot reload share recovery | ||
* refactor: remove server jsonp template | ||
- refactor: remove server jsonp template | ||
* chore: remove dead code from runtime modules | ||
- chore: remove dead code from runtime modules | ||
* fix: clean up jsonp getCustomJsonpCode | ||
- fix: clean up jsonp getCustomJsonpCode | ||
getting chunk loading global from compiler output options | ||
* feat: adding cleanInitArrays runtime helper | ||
- feat: adding cleanInitArrays runtime helper | ||
* chore: remove share scope hoist and module hoisting system | ||
- chore: remove share scope hoist and module hoisting system | ||
* chore: cleanup code | ||
- chore: cleanup code | ||
* chore: remove dead code from add module runtime plugin | ||
- chore: remove dead code from add module runtime plugin | ||
likely can remove whole plugin in future | ||
* chore: remove logs from delegate modules | ||
- chore: remove logs from delegate modules | ||
* chore: remove old utils | ||
- chore: remove old utils | ||
* fix: add warning on auto page stitch | ||
- fix: add warning on auto page stitch | ||
* fix: remove commented out code from InvertedContainerPlugin.ts | ||
- fix: remove commented out code from InvertedContainerPlugin.ts | ||
* chore: improve logging to see if its local load or remote load | ||
- chore: improve logging to see if its local load or remote load | ||
* chore: clean up old custom promises factories | ||
- chore: clean up old custom promises factories | ||
* fix: remove container proxy code | ||
- fix: remove container proxy code | ||
* fix: remove container proxy code | ||
- fix: remove container proxy code | ||
* chore: fix project.json | ||
- chore: fix project.json | ||
* debugging | ||
- debugging | ||
* fix: resolve backmerge issues with build | ||
- fix: resolve backmerge issues with build | ||
* Merge branch 'kill_child_compilers' into fix_backmerge_issues | ||
- Merge branch 'kill_child_compilers' into fix_backmerge_issues | ||
# Conflicts: | ||
# package-lock.json | ||
# package.json | ||
# packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts | ||
* feat: enable eager sharing | ||
# package-lock.json | ||
* refactor: improve module hooks for eager loading and search | ||
# package.json | ||
* refactor: cleanup custom jsonp and make es5 | ||
# packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts | ||
* refactor: cleanup inverted container code | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts | ||
* refactor: cleanup inverted container code | ||
* automaticAsyncBoundary option has been removed | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts | ||
* fix: exclude specific pages from page map automatically | ||
- feat: enable eager sharing | ||
* refactor: conslidate codebase | ||
- refactor: improve module hooks for eager loading and search | ||
* fix: improve hot reload share recovery | ||
- refactor: cleanup custom jsonp and make es5 | ||
* refactor: remove server jsonp template | ||
- refactor: cleanup inverted container code | ||
* chore: remove dead code from runtime modules | ||
- refactor: cleanup inverted container code | ||
- automaticAsyncBoundary option has been removed | ||
* fix: clean up jsonp getCustomJsonpCode | ||
- fix: exclude specific pages from page map automatically | ||
- refactor: conslidate codebase | ||
- fix: improve hot reload share recovery | ||
- refactor: remove server jsonp template | ||
- chore: remove dead code from runtime modules | ||
- fix: clean up jsonp getCustomJsonpCode | ||
getting chunk loading global from compiler output options | ||
* feat: adding cleanInitArrays runtime helper | ||
- feat: adding cleanInitArrays runtime helper | ||
* chore: remove share scope hoist and module hoisting system | ||
- chore: remove share scope hoist and module hoisting system | ||
* chore: cleanup code | ||
- chore: cleanup code | ||
* chore: remove dead code from add module runtime plugin | ||
- chore: remove dead code from add module runtime plugin | ||
likely can remove whole plugin in future | ||
* chore: remove logs from delegate modules | ||
- chore: remove logs from delegate modules | ||
* chore: remove old utils | ||
- chore: remove old utils | ||
* fix: add warning on auto page stitch | ||
- fix: add warning on auto page stitch | ||
* fix: remove commented out code from InvertedContainerPlugin.ts | ||
- fix: remove commented out code from InvertedContainerPlugin.ts | ||
* chore: improve logging to see if its local load or remote load | ||
- chore: improve logging to see if its local load or remote load | ||
* chore: clean up old custom promises factories | ||
- chore: clean up old custom promises factories | ||
* fix: remove container proxy code | ||
- fix: remove container proxy code | ||
* fix: remove container proxy code | ||
- fix: remove container proxy code | ||
* fix: resolve backmerge issues with build | ||
- fix: resolve backmerge issues with build | ||
* Merge branch 'kill_child_compilers' into fix_backmerge_issues | ||
- Merge branch 'kill_child_compilers' into fix_backmerge_issues | ||
# Conflicts: | ||
# package-lock.json | ||
# package.json | ||
# packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts | ||
* feat: enable eager sharing | ||
# package-lock.json | ||
* refactor: improve module hooks for eager loading and search | ||
# package.json | ||
* refactor: cleanup custom jsonp and make es5 | ||
# packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts | ||
* refactor: cleanup inverted container code | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts | ||
* refactor: cleanup inverted container code | ||
# packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts | ||
* ci: fix install step with npm and NX | ||
- feat: enable eager sharing | ||
* test: remove tests for now | ||
- refactor: improve module hooks for eager loading and search | ||
* chore(utils): release version 1.7.3-beta.0 | ||
- refactor: cleanup custom jsonp and make es5 | ||
* chore(utils): release version 1.7.3 | ||
- refactor: cleanup inverted container code | ||
* chore(node): release version 0.14.4-beta.0 | ||
- refactor: cleanup inverted container code | ||
* chore(node): release version 0.14.4 | ||
- ci: fix install step with npm and NX | ||
* chore(nextjs-mf): release version 6.4.1-beta.4 | ||
- test: remove tests for now | ||
* fix: remove debugging runtime variable | ||
- chore(utils): release version 1.7.3-beta.0 | ||
* chore(nextjs-mf): release version 6.4.1-beta.5 | ||
- chore(utils): release version 1.7.3 | ||
- chore(node): release version 0.14.4-beta.0 | ||
- chore(node): release version 0.14.4 | ||
- chore(nextjs-mf): release version 6.4.1-beta.4 | ||
- fix: remove debugging runtime variable | ||
- chore(nextjs-mf): release version 6.4.1-beta.5 | ||
## [1.0.7](https://github.com/module-federation/nextjs-mf/compare/node-1.0.6...node-1.0.7) (2023-08-14) | ||
@@ -270,0 +299,0 @@ |
{ | ||
"public": true, | ||
"name": "@module-federation/node", | ||
"version": "2.0.2-beta.2", | ||
"version": "2.0.2-beta.3", | ||
"type": "commonjs", | ||
@@ -17,2 +17,4 @@ "main": "./src/index.js", | ||
}, | ||
"./src/plugins/RemotePublicPathPlugin.js": "./src/plugins/RemotePublicPathPlugin.js", | ||
"./src/plugins/NodeFederationPlugin.js": "./src/plugins/NodeFederationPlugin.js", | ||
"./src/": "./src/" | ||
@@ -37,13 +39,19 @@ }, | ||
"dependencies": { | ||
"@module-federation/utilities": "3.0.2-beta.0", | ||
"encoding": "^0.1.13", | ||
"node-fetch": "^2.6.7", | ||
"encoding": "^0.1.13", | ||
"@module-federation/utilities": "3.0.2-beta.0" | ||
"tapable": "2.2.1", | ||
"webpack-sources": "3.2.3", | ||
"@module-federation/enhanced": "0.0.3" | ||
}, | ||
"peerDependencies": { | ||
"webpack": "^5.40.0", | ||
"next": "^12||^13", | ||
"react": "^16||^17||^18", | ||
"react-dom": "^16||^17||^18", | ||
"next": "^12||^13" | ||
"webpack": "^5.40.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"next": { | ||
"optional": true | ||
}, | ||
"react": { | ||
@@ -54,7 +62,4 @@ "optional": true | ||
"optional": true | ||
}, | ||
"next": { | ||
"optional": true | ||
} | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
export function fileSystemRunInContextStrategy(chunkId: any, rootOutputDir: any, remotes: any, callback: any): Promise<void>; | ||
export function httpEvalStrategy(chunkName: any, remoteName: any, remotes: any, callback: any): Promise<void>; | ||
export declare function fileSystemRunInContextStrategy(chunkId: any, rootOutputDir: any, remotes: any, callback: any): Promise<void>; | ||
export declare function httpEvalStrategy(chunkName: any, remoteName: any, remotes: any, callback: any): Promise<void>; | ||
/** | ||
@@ -11,2 +11,2 @@ * HttpVmStrategy | ||
*/ | ||
export function httpVmStrategy(chunkName: string, remoteName: string, remotes: object, callback: Function): Promise<void>; | ||
export declare function httpVmStrategy(chunkName: any, remoteName: any, remotes: any, callback: any): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.httpVmStrategy = exports.httpEvalStrategy = exports.fileSystemRunInContextStrategy = void 0; | ||
//@ts-nocheck | ||
async function fileSystemRunInContextStrategy(chunkId, rootOutputDir, remotes, callback) { | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var vm = require('vm'); | ||
var filename = require('path').join(__dirname, | ||
//eslint-disable-next-line | ||
rootOutputDir + __webpack_require__.u(chunkId)); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const vm = require('vm'); | ||
const filename = path.join(__dirname, rootOutputDir + __webpack_require__.u(chunkId)); | ||
if (fs.existsSync(filename)) { | ||
@@ -17,3 +16,3 @@ fs.readFile(filename, 'utf-8', (err, content) => { | ||
} | ||
var chunk = {}; | ||
const chunk = {}; | ||
try { | ||
@@ -39,5 +38,4 @@ vm.runInThisContext('(function(exports, require, __dirname, __filename) {' + | ||
async function httpEvalStrategy(chunkName, remoteName, remotes, callback) { | ||
var url; | ||
let url; | ||
try { | ||
// eslint-disable-next-line no-undef | ||
url = new URL(chunkName, __webpack_require__.p); | ||
@@ -48,13 +46,14 @@ } | ||
url = new URL(remotes[remoteName]); | ||
var getBasenameFromUrl = (url) => { | ||
const getBasenameFromUrl = (url) => { | ||
const urlParts = url.split('/'); | ||
return urlParts[urlParts.length - 1]; | ||
}; | ||
var fileToReplace = getBasenameFromUrl(url.pathname); | ||
const fileToReplace = getBasenameFromUrl(url.pathname); | ||
url.pathname = url.pathname.replace(fileToReplace, chunkName); | ||
} | ||
const data = await fetch(url).then((res) => res.text()); | ||
var chunk = {}; | ||
const chunk = {}; | ||
try { | ||
eval('(function(exports, require, __dirname, __filename) {' + data + '\n})', chunkName)(chunk, require, '.', chunkName); | ||
const urlDirname = url.pathname.split('/').slice(0, -1).join('/'); | ||
eval('(function(exports, require, __dirname, __filename) {' + data + '\n})', chunkName)(chunk, require, urlDirname, chunkName); | ||
callback(null, chunk); | ||
@@ -76,8 +75,8 @@ } | ||
async function httpVmStrategy(chunkName, remoteName, remotes, callback) { | ||
var http = require('http'); | ||
var https = require('https'); | ||
var vm = require('vm'); | ||
var url; | ||
const http = require('http'); | ||
const https = require('https'); | ||
const vm = require('vm'); | ||
const path = require('path'); | ||
let url; | ||
try { | ||
console.log('trying chunk load', chunkName, __webpack_require__.p); | ||
url = new URL(chunkName, __webpack_require__.p); | ||
@@ -87,8 +86,7 @@ } | ||
console.error('module-federation: failed to construct absolute chunk path of', remoteName, 'for', chunkName, e); | ||
console.log('fallbak url constructed', remotes._config[remoteName]); | ||
url = new URL(remotes._config[remoteName]); | ||
var fileToReplace = require('path').basename(url.pathname); | ||
const fileToReplace = path.basename(url.pathname); | ||
url.pathname = url.pathname.replace(fileToReplace, chunkName); | ||
} | ||
var protocol = url.protocol === 'https:' ? https : http; | ||
const protocol = url.protocol === 'https:' ? https : http; | ||
protocol.get(url, (res) => { | ||
@@ -100,4 +98,5 @@ let data = ''; | ||
res.on('end', () => { | ||
var chunk = {}; | ||
vm.runInThisContext('(function(exports, require, __dirname, __filename) {' + data + '\n})', chunkName)(chunk, require, '.', chunkName); | ||
const chunk = {}; | ||
const urlDirname = url.pathname.split('/').slice(0, -1).join('/'); | ||
vm.runInThisContext('(function(exports, require, __dirname, __filename) {' + data + '\n})', chunkName)(chunk, require, urlDirname, chunkName); | ||
callback(null, chunk); | ||
@@ -104,0 +103,0 @@ }); |
@@ -5,1 +5,4 @@ export { default as StreamingTargetPlugin } from './plugins/StreamingTargetPlugin'; | ||
export { default as ChunkCorrelationPlugin } from './plugins/ChunkCorrelationPlugin'; | ||
export { default as RemotePublicPathPlugin } from './plugins/RemotePublicPathRuntimeModule'; | ||
export { default as NodeContainerPlugin } from './plugins/NodeContainerPlugin'; | ||
export { parseRemotes } from './plugins/NodeFederationPlugin'; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ChunkCorrelationPlugin = exports.UniversalFederationPlugin = exports.NodeFederationPlugin = exports.StreamingTargetPlugin = void 0; | ||
exports.parseRemotes = exports.NodeContainerPlugin = exports.RemotePublicPathPlugin = exports.ChunkCorrelationPlugin = exports.UniversalFederationPlugin = exports.NodeFederationPlugin = exports.StreamingTargetPlugin = void 0; | ||
var StreamingTargetPlugin_1 = require("./plugins/StreamingTargetPlugin"); | ||
@@ -16,2 +16,8 @@ Object.defineProperty(exports, "StreamingTargetPlugin", { enumerable: true, get: function () { return __importDefault(StreamingTargetPlugin_1).default; } }); | ||
Object.defineProperty(exports, "ChunkCorrelationPlugin", { enumerable: true, get: function () { return __importDefault(ChunkCorrelationPlugin_1).default; } }); | ||
var RemotePublicPathRuntimeModule_1 = require("./plugins/RemotePublicPathRuntimeModule"); | ||
Object.defineProperty(exports, "RemotePublicPathPlugin", { enumerable: true, get: function () { return __importDefault(RemotePublicPathRuntimeModule_1).default; } }); | ||
var NodeContainerPlugin_1 = require("./plugins/NodeContainerPlugin"); | ||
Object.defineProperty(exports, "NodeContainerPlugin", { enumerable: true, get: function () { return __importDefault(NodeContainerPlugin_1).default; } }); | ||
var NodeFederationPlugin_2 = require("./plugins/NodeFederationPlugin"); | ||
Object.defineProperty(exports, "parseRemotes", { enumerable: true, get: function () { return NodeFederationPlugin_2.parseRemotes; } }); | ||
//# sourceMappingURL=index.js.map |
export = FederationStatsPlugin; | ||
/** | ||
* @typedef {object} FederationStatsPluginOptions | ||
* @property {string} filename The filename in the `output.path` directory to write stats to. | ||
* @property {string | string[]} filename The filename or an array of filenames in the `output.path` directory to write stats to. | ||
*/ | ||
@@ -27,5 +27,5 @@ /** | ||
/** | ||
* The filename in the `output.path` directory to write stats to. | ||
* The filename or an array of filenames in the `output.path` directory to write stats to. | ||
*/ | ||
filename: string; | ||
filename: string | string[]; | ||
}; | ||
@@ -32,0 +32,0 @@ type WebpackStats = any; |
@@ -260,3 +260,3 @@ "use strict"; | ||
* @typedef {object} FederationStatsPluginOptions | ||
* @property {string} filename The filename in the `output.path` directory to write stats to. | ||
* @property {string | string[]} filename The filename or an array of filenames in the `output.path` directory to write stats to. | ||
*/ | ||
@@ -413,10 +413,26 @@ /** | ||
const { filename } = this._options; | ||
// Check if an asset with the same filename already exists. | ||
const asset = compilation.getAsset(filename); | ||
// If an asset with the same filename already exists, update it. Otherwise, create a new asset. | ||
if (asset) { | ||
compilation.updateAsset(filename, statsSource); | ||
// If filename is an array, loop over it to emit or update assets. | ||
if (Array.isArray(filename)) { | ||
for (const file of filename) { | ||
// Check if an asset with the same filename already exists. | ||
const asset = compilation.getAsset(file); | ||
// If an asset with the same filename already exists, update it. Otherwise, create a new asset. | ||
if (asset) { | ||
compilation.updateAsset(file, statsSource); | ||
} | ||
else { | ||
compilation.emitAsset(file, statsSource); | ||
} | ||
} | ||
} | ||
else { | ||
compilation.emitAsset(filename, statsSource); | ||
// Check if an asset with the same filename already exists. | ||
const asset = compilation.getAsset(filename); | ||
// If an asset with the same filename already exists, update it. Otherwise, create a new asset. | ||
if (asset) { | ||
compilation.updateAsset(filename, statsSource); | ||
} | ||
else { | ||
compilation.emitAsset(filename, statsSource); | ||
} | ||
} | ||
@@ -423,0 +439,0 @@ }); |
import type { Compiler } from 'webpack'; | ||
import type { ModuleFederationPluginOptions } from '../types'; | ||
interface CommonJsChunkLoadingOptions extends ModuleFederationPluginOptions { | ||
interface DynamicFilesystemChunkLoadingOptions extends ModuleFederationPluginOptions { | ||
baseURI: Compiler['options']['output']['publicPath']; | ||
@@ -11,8 +11,8 @@ promiseBaseURI?: string; | ||
} | ||
declare class CommonJsChunkLoadingPlugin { | ||
declare class DynamicFilesystemChunkLoadingPlugin { | ||
private options; | ||
private _asyncChunkLoading; | ||
constructor(options: CommonJsChunkLoadingOptions); | ||
constructor(options: DynamicFilesystemChunkLoadingOptions); | ||
apply(compiler: Compiler): void; | ||
} | ||
export default CommonJsChunkLoadingPlugin; | ||
export default DynamicFilesystemChunkLoadingPlugin; |
@@ -9,5 +9,4 @@ "use strict"; | ||
const DynamicFilesystemChunkLoadingRuntimeModule_1 = __importDefault(require("./DynamicFilesystemChunkLoadingRuntimeModule")); | ||
const FederationModuleInfoRuntimeModule_1 = __importDefault(require("./FederationModuleInfoRuntimeModule")); | ||
const RemotePublicPathRuntimeModule_1 = __importDefault(require("./RemotePublicPathRuntimeModule")); | ||
class CommonJsChunkLoadingPlugin { | ||
class DynamicFilesystemChunkLoadingPlugin { | ||
constructor(options) { | ||
@@ -24,4 +23,5 @@ this.options = options || {}; | ||
asyncChunkLoading: this._asyncChunkLoading, | ||
//@ts-ignore | ||
}).apply(compiler); | ||
compiler.hooks.thisCompilation.tap('CommonJsChunkLoadingPlugin', (compilation) => { | ||
compiler.hooks.thisCompilation.tap('DynamicFilesystemChunkLoadingPlugin', (compilation) => { | ||
// Always enabled | ||
@@ -48,21 +48,21 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
.for(RuntimeGlobals_1.default.ensureChunkHandlers) | ||
.tap('CommonJsChunkLoadingPlugin', handler); | ||
.tap('DynamicFilesystemChunkLoadingPlugin', handler); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals_1.default.hmrDownloadUpdateHandlers) | ||
.tap('CommonJsChunkLoadingPlugin', handler); | ||
.tap('DynamicFilesystemChunkLoadingPlugin', handler); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals_1.default.hmrDownloadManifest) | ||
.tap('CommonJsChunkLoadingPlugin', handler); | ||
.tap('DynamicFilesystemChunkLoadingPlugin', handler); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals_1.default.baseURI) | ||
.tap('CommonJsChunkLoadingPlugin', handler); | ||
.tap('DynamicFilesystemChunkLoadingPlugin', handler); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals_1.default.externalInstallChunk) | ||
.tap('CommonJsChunkLoadingPlugin', handler); | ||
.tap('DynamicFilesystemChunkLoadingPlugin', handler); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals_1.default.onChunksLoaded) | ||
.tap('CommonJsChunkLoadingPlugin', handler); | ||
.tap('DynamicFilesystemChunkLoadingPlugin', handler); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals_1.default.ensureChunkHandlers) | ||
.tap('CommonJsChunkLoadingPlugin', (chunk, set) => { | ||
.tap('DynamicFilesystemChunkLoadingPlugin', (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) { | ||
@@ -75,3 +75,3 @@ return; | ||
.for(RuntimeGlobals_1.default.hmrDownloadUpdateHandlers) | ||
.tap('CommonJsChunkLoadingPlugin', (chunk, set) => { | ||
.tap('DynamicFilesystemChunkLoadingPlugin', (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) { | ||
@@ -87,3 +87,3 @@ return; | ||
.for(RuntimeGlobals_1.default.hmrDownloadManifest) | ||
.tap('CommonJsChunkLoadingPlugin', (chunk, set) => { | ||
.tap('DynamicFilesystemChunkLoadingPlugin', (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) { | ||
@@ -96,3 +96,3 @@ return; | ||
.for(RuntimeGlobals_1.default.publicPath) | ||
.tap("RuntimePlugin", (chunk, set) => { | ||
.tap('RuntimePlugin', (chunk, set) => { | ||
const { outputOptions } = compilation; | ||
@@ -105,6 +105,7 @@ const { publicPath: globalPublicPath, scriptType } = outputOptions; | ||
const module = new RemotePublicPathRuntimeModule_1.default(this.options); | ||
if (publicPath === "auto" && scriptType !== "module") { | ||
if (publicPath === 'auto' && scriptType !== 'module') { | ||
set.add(RuntimeGlobals_1.default.global); | ||
} | ||
else if (typeof publicPath !== "string" || /\[(full)?hash\]/.test(publicPath)) { | ||
else if (typeof publicPath !== 'string' || | ||
/\[(full)?hash\]/.test(publicPath)) { | ||
module.fullHash = true; | ||
@@ -116,5 +117,7 @@ } | ||
compilation.hooks.additionalTreeRuntimeRequirements.tap('StartupChunkDependenciesPlugin', (chunk, set, { chunkGraph }) => { | ||
compilation.addRuntimeModule(chunk, | ||
//@ts-ignore | ||
new FederationModuleInfoRuntimeModule_1.default()); | ||
// compilation.addRuntimeModule( | ||
// chunk, | ||
// //@ts-ignore | ||
// new FederationModuleInfoRuntimeModule(), | ||
// ); | ||
}); | ||
@@ -124,3 +127,3 @@ }); | ||
} | ||
exports.default = CommonJsChunkLoadingPlugin; | ||
exports.default = DynamicFilesystemChunkLoadingPlugin; | ||
//# sourceMappingURL=CommonJsChunkLoadingPlugin.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
const compileBooleanMatcher_1 = __importDefault(require("webpack/lib/util/compileBooleanMatcher")); | ||
const parts_1 = require("./parts"); | ||
const webpackChunkUtilities_1 = require("./webpackChunkUtilities"); | ||
const stratagies_1 = require("../filesystem/stratagies"); | ||
@@ -80,3 +80,3 @@ //hook can be tapped with | ||
const hasJsMatcher = (0, compileBooleanMatcher_1.default)(conditionMap); | ||
const initialChunkIds = (0, parts_1.getInitialChunkIds)(chunk, chunkGraph, chunkHasJs); | ||
const initialChunkIds = (0, webpackChunkUtilities_1.getInitialChunkIds)(chunk, chunkGraph, chunkHasJs); | ||
const outputName = compilation.getPath(jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions), { chunk, contentHashType: 'javascript' }); | ||
@@ -102,3 +102,3 @@ const rootOutputDir = (0, identifier_1.getUndoPath)(outputName, compilation.outputOptions.path, false); | ||
]), | ||
'};' | ||
'};', | ||
]); | ||
@@ -111,5 +111,7 @@ const remoteRegistry = webpack_1.Template.asString([ | ||
}, {}))};`, | ||
`Object.keys(remotes).forEach(function(remote) { | ||
globalThis.__remote_scope__._config[remote] = remotes[remote]; | ||
});`, | ||
webpack_1.Template.asString([ | ||
'Object.keys(remotes).forEach(function(remote) {', | ||
webpack_1.Template.indent('globalThis.__remote_scope__._config[remote] = remotes[remote];'), | ||
'});', | ||
]), | ||
]); | ||
@@ -129,18 +131,18 @@ return webpack_1.Template.asString([ | ||
'', | ||
(0, parts_1.handleOnChunkLoad)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded), runtimeTemplate), | ||
(0, webpackChunkUtilities_1.handleOnChunkLoad)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded), runtimeTemplate), | ||
'', | ||
(0, parts_1.generateInstallChunk)(runtimeTemplate, this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded)), | ||
(0, webpackChunkUtilities_1.generateInstallChunk)(runtimeTemplate, this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded)), | ||
'', | ||
this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers) | ||
? (0, parts_1.generateLoadScript)(runtimeTemplate) | ||
? (0, webpackChunkUtilities_1.generateLoadScript)(runtimeTemplate) | ||
: '// no remote script loader needed', | ||
this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers) | ||
? (0, parts_1.generateLoadingCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name) | ||
? (0, webpackChunkUtilities_1.generateLoadingCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name) | ||
: '// no chunk loading', | ||
'', | ||
(0, parts_1.generateExternalInstallChunkCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.externalInstallChunk), this.options.debug), | ||
(0, webpackChunkUtilities_1.generateExternalInstallChunkCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.externalInstallChunk), this.options.debug), | ||
'', | ||
(0, parts_1.generateHmrCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir), | ||
(0, webpackChunkUtilities_1.generateHmrCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir), | ||
'', | ||
(0, parts_1.generateHmrManifestCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadManifest), rootOutputDir), | ||
(0, webpackChunkUtilities_1.generateHmrManifestCode)(this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadManifest), rootOutputDir), | ||
]); | ||
@@ -147,0 +149,0 @@ } |
@@ -12,3 +12,2 @@ import type { Compiler, container } from 'webpack'; | ||
debug?: boolean; | ||
useRemoteSideloader?: boolean; | ||
} | ||
@@ -63,3 +62,7 @@ /** | ||
apply(compiler: Compiler): void; | ||
private preparePluginOptions; | ||
private updateCompilerOptions; | ||
private getModuleFederationPlugin; | ||
private loadModuleFederationPlugin; | ||
} | ||
export default NodeFederationPlugin; |
@@ -5,10 +5,3 @@ 'use strict'; | ||
const pure_1 = require("@module-federation/utilities/src/utils/pure"); | ||
// possible remote evaluators | ||
// this depends on the chunk format selected. | ||
// commonjs2 - it think, is lazily evaluated - beware | ||
// const remote = eval(scriptContent + '\n try{' + moduleName + '}catch(e) { null; };'); | ||
// commonjs - fine to use but exports marker doesnt exist | ||
// const remote = eval('let exports = {};' + scriptContent + 'exports'); | ||
// commonjs-module, ideal since it returns a commonjs module format | ||
// const remote = eval(scriptContent + 'module.exports') | ||
const enhanced_1 = require("@module-federation/enhanced"); | ||
/** | ||
@@ -29,3 +22,4 @@ * This function iterates over all remotes and checks if they | ||
const isInternal = value.startsWith('internal '); | ||
const isGlobal = value.includes('@') && !['window.', 'global.', 'globalThis.', 'self.'].some(prefix => value.startsWith(prefix)); | ||
const isGlobal = value.includes('@') && | ||
!['window.', 'global.', 'globalThis.', 'self.'].some((prefix) => value.startsWith(prefix)); | ||
acc[key] = isInternal || !isGlobal ? value : (0, exports.parseRemoteSyntax)(value); | ||
@@ -50,3 +44,3 @@ return acc; | ||
const [url, global] = (0, pure_1.extractUrlAndGlobal)(remote); | ||
if (!['window.', 'global.', 'globalThis.'].some(prefix => global.startsWith(prefix))) { | ||
if (!['window.', 'global.', 'globalThis.'].some((prefix) => global.startsWith(prefix))) { | ||
return `globalThis.__remote_scope__.${global}@${url}`; | ||
@@ -80,9 +74,18 @@ } | ||
apply(compiler) { | ||
// When used with Next.js, context is needed to use Next.js webpack | ||
const { webpack } = compiler; | ||
const pluginOptions = { | ||
new enhanced_1.ModuleInfoRuntimePlugin().apply(compiler); | ||
const pluginOptions = this.preparePluginOptions(); | ||
this.updateCompilerOptions(compiler); | ||
const ModuleFederationPlugin = this.getModuleFederationPlugin(compiler, webpack); | ||
new ModuleFederationPlugin(pluginOptions).apply(compiler); | ||
} | ||
preparePluginOptions() { | ||
return { | ||
...this._options, | ||
remotes: this._options.remotes ? (0, exports.parseRemotes)(this._options.remotes) : {}, | ||
remotes: this._options.remotes | ||
? (0, exports.parseRemotes)(this._options.remotes) | ||
: {}, | ||
}; | ||
//TODO can use import meta mock object but need to update data structure of remote_scope | ||
} | ||
updateCompilerOptions(compiler) { | ||
if (compiler.options && compiler.options.output) { | ||
@@ -93,12 +96,34 @@ compiler.options.output.importMetaName = 'remoteContainerRegistry'; | ||
const uniqueName = compiler?.options?.output?.uniqueName || this._options.name; | ||
if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) { | ||
if (typeof chunkFileName === 'string' && | ||
uniqueName && | ||
!chunkFileName.includes(uniqueName)) { | ||
const suffix = `-[chunkhash].js`; | ||
compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix); | ||
} | ||
new (this.context.ModuleFederationPlugin || | ||
(webpack && webpack.container.ModuleFederationPlugin) || | ||
require('webpack/lib/container/ModuleFederationPlugin'))(pluginOptions).apply(compiler); | ||
} | ||
getModuleFederationPlugin(compiler, webpack) { | ||
let ModuleFederationPlugin; | ||
if (this.context.ModuleFederationPlugin) { | ||
ModuleFederationPlugin = this.context.ModuleFederationPlugin; | ||
} | ||
else if (webpack && webpack.container && webpack.container.ModuleFederationPlugin) { | ||
ModuleFederationPlugin = webpack.container.ModuleFederationPlugin; | ||
} | ||
else { | ||
ModuleFederationPlugin = this.loadModuleFederationPlugin(); | ||
} | ||
return ModuleFederationPlugin; | ||
} | ||
loadModuleFederationPlugin() { | ||
let ModuleFederationPlugin; | ||
try { | ||
ModuleFederationPlugin = require('@module-federation/enhanced').ModuleFederationPlugin; | ||
} | ||
catch (e) { | ||
ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); | ||
} | ||
return ModuleFederationPlugin; | ||
} | ||
} | ||
exports.default = NodeFederationPlugin; | ||
//# sourceMappingURL=NodeFederationPlugin.js.map |
@@ -1,5 +0,5 @@ | ||
export default AutoPublicPathRuntimeModule; | ||
import { RuntimeModule } from 'webpack'; | ||
declare class AutoPublicPathRuntimeModule extends RuntimeModule { | ||
private options; | ||
constructor(options: any); | ||
options: any; | ||
/** | ||
@@ -10,2 +10,2 @@ * @returns {string} runtime code | ||
} | ||
import { RuntimeModule } from "webpack"; | ||
export default AutoPublicPathRuntimeModule; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const webpack_1 = require("webpack"); | ||
//@ts-ignore | ||
const identifier_1 = require("webpack/lib/util/identifier"); | ||
class AutoPublicPathRuntimeModule extends webpack_1.RuntimeModule { | ||
constructor(options) { | ||
super("publicPath", webpack_1.RuntimeModule.STAGE_BASIC + 1); | ||
super('publicPath', webpack_1.RuntimeModule.STAGE_BASIC + 1); | ||
this.options = options; | ||
@@ -15,30 +16,45 @@ } | ||
const { compilation } = this; | ||
const { scriptType, path, publicPath, importMetaName, uniqueName, chunkLoading } = compilation.outputOptions; | ||
const getPath = () => { | ||
return compilation.getPath(publicPath || "", { | ||
hash: compilation.hash || "XXXX" | ||
}); | ||
}; | ||
const { scriptType, path, publicPath, importMetaName, uniqueName, chunkLoading, | ||
//@ts-ignore | ||
} = compilation.outputOptions; | ||
const getPath = () => compilation?.getPath(publicPath || '', { | ||
hash: compilation?.hash || 'XXXX', | ||
}); | ||
// If publicPath is not "auto", return the static value | ||
if (publicPath !== "auto") { | ||
return `${webpack_1.RuntimeGlobals.publicPath} = ${JSON.stringify(getPath())};`; | ||
} | ||
const chunkName = compilation.getPath(webpack_1.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(this.chunk, compilation.outputOptions), { | ||
// if (publicPath !== 'auto') { | ||
// const path = getPath(); | ||
// return Template.asString([ | ||
// `${RuntimeGlobals.publicPath} = ${JSON.stringify(path)};`, | ||
// 'var addProtocol = (url)=> url.startsWith(\'//\') ? \'https:\' + url : url;', | ||
// `globalThis.currentVmokPublicPath = addProtocol(${RuntimeGlobals.publicPath}) || '/';`, | ||
// ]); | ||
// } | ||
const chunkName = compilation?.getPath(webpack_1.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(this.chunk, compilation?.outputOptions), { | ||
chunk: this.chunk, | ||
contentHashType: "javascript" | ||
contentHashType: 'javascript', | ||
}); | ||
const undoPath = (0, identifier_1.getUndoPath)(chunkName, path, false); | ||
const ident = webpack_1.Template.toIdentifier(uniqueName); | ||
const ident = webpack_1.Template.toIdentifier(uniqueName || ''); | ||
// Define potential lookup keys | ||
const potentialLookups = [this.chunk?.name, ident, uniqueName]; | ||
// Generate lookup string using potential keys | ||
const lookupString = potentialLookups | ||
.filter(Boolean) | ||
.map((lookup) => { | ||
return `remoteReg[${JSON.stringify(lookup)}]`; | ||
}) | ||
.join(' || '); | ||
return webpack_1.Template.asString([ | ||
"var scriptUrl;", | ||
'var scriptUrl;', | ||
// its an esproxy so nesting into _config directly is not possible | ||
"var remoteReg = globalThis.__remote_scope__._config;", | ||
` | ||
let remoteContainerRegistry = { | ||
get url() { | ||
return remoteReg[${JSON.stringify(ident)}]; | ||
var remoteReg = globalThis.__remote_scope__ ? globalThis.__remote_scope__._config : {}; | ||
return ${lookupString} | ||
} | ||
}; | ||
`, | ||
(['module', 'node', 'async-node', 'require'].includes(scriptType) || chunkLoading) | ||
['module', 'node', 'async-node', 'require'].includes(scriptType || '') || | ||
chunkLoading | ||
? webpack_1.Template.asString([ | ||
@@ -51,9 +67,15 @@ 'try {', | ||
webpack_1.Template.indent([ | ||
`if (typeof remoteContainerRegistry.url === "string") {`, | ||
'if (typeof remoteContainerRegistry.url === "string") {', | ||
webpack_1.Template.indent('scriptUrl = remoteContainerRegistry.url;'), | ||
'} else if(typeof __filename !== "undefined") {', | ||
webpack_1.Template.indent('scriptUrl = __filename;'), | ||
'} else {', | ||
webpack_1.Template.indent('scriptUrl = __filename;'), | ||
webpack_1.Template.indent([ | ||
`scriptUrl = ${publicPath !== 'auto' | ||
? JSON.stringify(getPath()) | ||
: 'undefined'}`, | ||
]), | ||
'}', | ||
]), | ||
'}' | ||
'}', | ||
]) | ||
@@ -63,17 +85,17 @@ : webpack_1.Template.asString([ | ||
`var document = ${webpack_1.RuntimeGlobals.global}.document;`, | ||
"if (!scriptUrl && document) {", | ||
'if (!scriptUrl && document) {', | ||
webpack_1.Template.indent([ | ||
`if (document.currentScript)`, | ||
webpack_1.Template.indent(`scriptUrl = document.currentScript.src`), | ||
"if (!scriptUrl) {", | ||
'if (document.currentScript)', | ||
webpack_1.Template.indent('scriptUrl = document.currentScript.src'), | ||
'if (!scriptUrl) {', | ||
webpack_1.Template.indent([ | ||
'var scripts = document.getElementsByTagName("script");', | ||
"if(scripts.length) scriptUrl = scripts[scripts.length - 1].src" | ||
'if(scripts.length) scriptUrl = scripts[scripts.length - 1].src', | ||
]), | ||
"}" | ||
'}', | ||
]), | ||
"}", | ||
'}', | ||
]), | ||
"console.log('scriptUrl', scriptUrl);", | ||
"// When supporting server environments where an automatic publicPath is not supported, you must specify an output.publicPath manually via configuration", | ||
// 'console.log(\'scriptUrl\', scriptUrl);', | ||
'// When supporting server environments where an automatic publicPath is not supported, you must specify an output.publicPath manually via configuration', | ||
'// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', | ||
@@ -84,3 +106,5 @@ 'if (!scriptUrl) throw new Error("Unable to calculate automatic public path");', | ||
? `${webpack_1.RuntimeGlobals.publicPath} = scriptUrl;` | ||
: `${webpack_1.RuntimeGlobals.publicPath} = scriptUrl + ${JSON.stringify(undoPath)};` | ||
: `${webpack_1.RuntimeGlobals.publicPath} = scriptUrl + ${JSON.stringify(undoPath)};`, | ||
"var addProtocol = (url)=> url.startsWith('//') ? 'https:' + url : url;", | ||
`globalThis.currentVmokPublicPath = addProtocol(${webpack_1.RuntimeGlobals.publicPath}) || '/';`, | ||
]); | ||
@@ -87,0 +111,0 @@ } |
@@ -152,2 +152,3 @@ "use strict"; | ||
const hostStats = loadHostStats(); | ||
console.log('hostStats', hostStats); | ||
const shareMap = createShareMap(); | ||
@@ -154,0 +155,0 @@ const allFlushed = await Promise.all(Array.from(exports.usedChunks).map(async (chunk) => processChunk(chunk, shareMap, hostStats))); |
@@ -1,1 +0,7 @@ | ||
export declare const revalidate: () => Promise<boolean>; | ||
export declare const performReload: (shouldReload: any) => boolean; | ||
export declare const checkUnreachableRemote: (remoteScope: any) => boolean; | ||
export declare const checkMedusaConfigChange: (remoteScope: any, fetchModule: any) => boolean; | ||
export declare const checkFakeRemote: (remoteScope: any) => boolean; | ||
export declare const fetchRemote: (remoteScope: any, fetchModule: any) => Promise<any[]>; | ||
export declare const revalidate: (remoteScope?: any, fetchModule?: any) => Promise<boolean>; | ||
export declare function getFetchModule(): any; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.revalidate = void 0; | ||
exports.getFetchModule = exports.revalidate = exports.fetchRemote = exports.checkFakeRemote = exports.checkMedusaConfigChange = exports.checkUnreachableRemote = exports.performReload = void 0; | ||
const hashmap = {}; | ||
@@ -23,10 +23,3 @@ const crypto_1 = __importDefault(require("crypto")); | ||
//@ts-ignore | ||
globalThis.__remote_scope__ = { | ||
_config: {}, | ||
_medusa: {}, | ||
}; | ||
//@ts-ignore | ||
globalThis.backupScope = {}; | ||
//@ts-ignore | ||
globalThis.factoryTracker = {}; | ||
globalThis.__remote_scope__ = {}; | ||
Object.keys(req.cache).forEach((key) => { | ||
@@ -39,95 +32,107 @@ if (requireCacheRegex.test(key)) { | ||
}; | ||
/* | ||
This code is doing two things First it checks if there are any fake remotes in the | ||
global scope If so then we need to reload the server because a remote has changed | ||
and needs to be fetched again Second it checks for each remote that was loaded by | ||
webpack whether its hash has changed since last time or not | ||
*/ | ||
const revalidate = () => { | ||
exports.performReload = performReload; | ||
const checkUnreachableRemote = (remoteScope) => { | ||
for (const property in remoteScope.remotes) { | ||
if (!remoteScope[property]) { | ||
console.log(remoteScope, property); | ||
console.error('unreachable remote found', property, 'hot reloading to refetch'); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
exports.checkUnreachableRemote = checkUnreachableRemote; | ||
const checkMedusaConfigChange = (remoteScope, fetchModule) => { | ||
//@ts-ignore | ||
if (globalThis.__remote_scope__) { | ||
if (remoteScope._medusa) { | ||
//@ts-ignore | ||
const remoteScope = globalThis.__remote_scope__; | ||
return new Promise((res) => { | ||
const fetches = []; | ||
for (const property in remoteScope) { | ||
if (remoteScope[property].fake) { | ||
console.error('unreachable remote found', property, 'hot reloading to refetch'); | ||
res(true); | ||
break; | ||
for (const property in remoteScope._medusa) { | ||
fetchModule(property) | ||
.then((res) => res.json()) | ||
.then((medusaResponse) => { | ||
if (medusaResponse.version !== | ||
//@ts-ignore | ||
remoteScope?._medusa[property].version) { | ||
console.log('medusa config changed', property, 'hot reloading to refetch'); | ||
(0, exports.performReload)(true); | ||
return true; | ||
} | ||
}); | ||
} | ||
} | ||
return false; | ||
}; | ||
exports.checkMedusaConfigChange = checkMedusaConfigChange; | ||
const checkFakeRemote = (remoteScope) => { | ||
for (const property in remoteScope._config) { | ||
let remote = remoteScope._config[property]; | ||
const resolveRemote = async () => { | ||
remote = await remote(); | ||
}; | ||
if (typeof remote === 'function') { | ||
resolveRemote(); | ||
} | ||
if (remote.fake) { | ||
console.log('fake remote found', property, 'hot reloading to refetch'); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
exports.checkFakeRemote = checkFakeRemote; | ||
const fetchRemote = (remoteScope, fetchModule) => { | ||
const fetches = []; | ||
for (const property in remoteScope._config) { | ||
const name = property; | ||
const url = remoteScope._config[property]; | ||
const fetcher = fetchModule(url) | ||
.then((re) => { | ||
if (!re.ok) { | ||
throw new Error(`Error loading remote: status: ${re.status}, content-type: ${re.headers.get('content-type')}`); | ||
} | ||
const fetchModule = getFetchModule(); | ||
if (remoteScope._medusa) { | ||
for (const property in remoteScope._medusa) { | ||
fetchModule(property) | ||
.then((res) => res.json()) | ||
.then((medusaResponse) => { | ||
//@ts-ignore | ||
if (medusaResponse.version !== | ||
//@ts-ignore | ||
remoteScope?._medusa[property].version) { | ||
console.log('medusa config changed', property, 'hot reloading to refetch'); | ||
performReload(true); | ||
return res(true); | ||
} | ||
}); | ||
return re.text(); | ||
}) | ||
.then((contents) => { | ||
const hash = crypto_1.default | ||
.createHash('md5') | ||
.update(contents) | ||
.digest('hex'); | ||
if (hashmap[name]) { | ||
if (hashmap[name] !== hash) { | ||
hashmap[name] = hash; | ||
console.log(name, 'hash is different - must hot reload server'); | ||
return true; | ||
} | ||
} | ||
for (const property in remoteScope._config) { | ||
let remote = remoteScope._config[property]; | ||
const resolveRemote = async () => { | ||
remote = await remote(); | ||
}; | ||
if (typeof remote === 'function') { | ||
resolveRemote(); | ||
} | ||
if (remote.fake) { | ||
console.log('fake remote found', property, 'hot reloading to refetch'); | ||
res(true); | ||
} | ||
const name = property; | ||
const url = remote; | ||
const fetcher = fetchModule(url) | ||
.then((re) => { | ||
if (!re.ok) { | ||
throw new Error(`Error loading remote: status: ${re.status}, content-type: ${re.headers.get('content-type')}`); | ||
} | ||
return re.text(); | ||
}) | ||
.then((contents) => { | ||
const hash = crypto_1.default | ||
.createHash('md5') | ||
.update(contents) | ||
.digest('hex'); | ||
if (hashmap[name]) { | ||
if (hashmap[name] !== hash) { | ||
hashmap[name] = hash; | ||
console.log(name, 'hash is different - must hot reload server'); | ||
res(true); | ||
} | ||
} | ||
else { | ||
hashmap[name] = hash; | ||
} | ||
}) | ||
.catch((e) => { | ||
console.error('Remote', name, url, 'Failed to load or is not online', e); | ||
}); | ||
fetches.push(fetcher); | ||
else { | ||
hashmap[name] = hash; | ||
} | ||
Promise.all(fetches).then(() => res(false)); | ||
}).then((shouldReload) => { | ||
return performReload(shouldReload); | ||
}) | ||
.catch((e) => { | ||
console.error('Remote', name, url, 'Failed to load or is not online', e); | ||
}); | ||
fetches.push(fetcher); | ||
} | ||
return Promise.resolve(false); | ||
return Promise.all(fetches); | ||
}; | ||
exports.fetchRemote = fetchRemote; | ||
//@ts-ignore | ||
const revalidate = (remoteScope = globalThis.__remote_scope__ || {}, fetchModule = getFetchModule() || (() => { })) => { | ||
return new Promise((res) => { | ||
if ((0, exports.checkUnreachableRemote)(remoteScope)) { | ||
res(true); | ||
} | ||
// @ts-ignore | ||
if ((0, exports.checkMedusaConfigChange)(remoteScope, fetchModule)) { | ||
res(true); | ||
} | ||
if ((0, exports.checkFakeRemote)(remoteScope)) { | ||
res(true); | ||
} | ||
(0, exports.fetchRemote)(remoteScope, fetchModule).then(() => res(false)); | ||
}).then((shouldReload) => { | ||
return (0, exports.performReload)(shouldReload); | ||
}); | ||
}; | ||
exports.revalidate = revalidate; | ||
/* | ||
This code is importing the nodefetch module and assigning it to a variable named | ||
node Fetch The code then checks if there\'s an existing global object called webpack | ||
Chunk Load which is used by webpack If so we use that instead of nodefetch This | ||
allows us to use fetch in our tests without having to mock out nodefetch | ||
*/ | ||
function getFetchModule() { | ||
@@ -143,2 +148,3 @@ //@ts-ignore | ||
} | ||
exports.getFetchModule = getFetchModule; | ||
//# sourceMappingURL=hot-reload.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228101
2407
10
+ Addedtapable@2.2.1
+ Addedwebpack-sources@3.2.3
+ Added@module-federation/enhanced@0.0.3(transitive)