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

Conversation

ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy commented Aug 29, 2023

The Infra Team has implemented substantial improvements to federation internally.
While the node plugin is still WIP, this is the beginning of unifying our ecosystems.

update: Since initial commits, this has evolved. As we plan to implement node federation into rspack natively. We have gotten some guidance on how to design a dynamic fileystem in a non-hacky manner. So this now includes:

  • Universal AutomaticPublicPath - can calculate dynamic asset prefixes in any environment with a single runtime
  • Dynamic Filesystem (DFS) - pluggable filesystem layer that allows use of many different "filesystems" that can be used to load chunks. Like http or local fs, or redit, or socket adapters can all be created
  • FederationRuntimeModule - a mini SDK that you can access local and global information about the system at runtime.
  • Native chunk loading - no more hacks to inject server remote entries. webpack now undertstands the @ syntax and all other patterns from externalTypes natively. So the surface area of custom code beyond the filesystem is reduced and we can rely on standard webpack chunk loading mechaincs by teaching the runtime a few new tricks.

Update:
This PR has grown in scope

  • Async Boundary Plugin - no longer need import() for federation to work, eager sharing issues and call undefined issues no longer exist
  • Embedded Container Plugin - support for runtimeChunk: single
  • Tweaks to module federation to allow it to track non async chunks
  • Removal of most hacks used in past

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.

ScriptedAlchemy and others added 28 commits September 6, 2023 17:33
…mprove_auto_public_path

# Conflicts:
#	packages/node/src/plugins/FederationModuleInfoRuntimeModule.ts
#	packages/node/src/plugins/RemotePublicPathRuntimeModule.js
#	packages/node/src/plugins/loadScript.ts
…nction

This commit enhances the readability of the httpVmStrategy by providing comprehensive inline documentation. The comments explain the purpose of the function, its parameters, and what it does. This will aid future developers in understanding the purpose and usage of the httpVmStrategy function.

### packages/node/src/filesystem/stratagies.js

- Added comprehensive inline documentation for the httpVmStrategy function
Refactoring and Enhancements of Node Federation Plugin and Filesystem Strategy, Including Addition of New Features and Tests
This commit includes refactoring of DelegateModulesPlugin.ts. Changes involve updating data structures, adjusting logic for handling modules and dependencies and moving the resolveDelegateModules functionality in the apply method.

### packages/utilities/src/plugins/DelegateModulesPlugin.ts

- changed Set data structure of _delegateModules to Map

- adjusted logic to handle modules and dependencies using forEach instead of looping with 'for' keyword

- replaced 'set' with 'add' keyword to add modules to _delegateModules

- moved resolveDelegateModules functionality inside the apply method
# Conflicts:
#	package-lock.json
#	package.json
#	packages/nextjs-mf/src/default-delegate.ts
#	packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts
#	packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts
#	packages/utilities/src/plugins/DelegateModulesPlugin.ts
…ublic_path)

Updated DelegateModulesPlugin to use 'const' in for-of loops and added
'thisCompilation' hook. Adjusted test cases to reflect these changes. Also,
updated DynamicFilesystemRuntimeModule to remove unused 'RuntimeGlobals'
import.
…ts (#node_auto_public_path)

Removed unutilized 'importMetaName' from RemotePublicPathRuntimeModule. Updated NodeFederationPlugin.parseRemotes.test.js to reflect changes in global and remote scope naming conventions.
…_public_path

Enable webpack devMiddleware to write to disk in development mode. This allows developers to view and debug the output files generated by webpack during development.
…ic_path)

This commit adds support for automatically setting the public path for
remote modules. This feature allows for dynamic path resolution based on
the publicPath value in the outputOptions of the webpack configuration.
If the publicPath value is set to "auto", the path is automatically
resolved, otherwise, the static value of publicPath is used. This change
provides more flexibility in setting the public path for remote modules.
…node_auto_public_path

Updated CommonJsChunkLoadingPlugin to automatically set the public path from options instead of using a constant value. Also enhanced the chunk loading strategy to provide better logging and fallback options in scenarios where the chunk load fails. This will improve the maintainability and debugging of chunk loading processes.
# Conflicts:
#	package-lock.json
#	package.json
#	packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts
#	packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts
…edance)

The createDelegatedModule utility from the nextjs-mf package was commented out,
indicating no longer necessary for the checkout app's next.config.js. Also, a
jest environment was added to the eslint configuration in the node package, and
the generated comments and ts-ignore directives were removed from the test file
for parseRemotes in the NodeFederationPlugin.
# Conflicts:
#	package-lock.json
#	packages/node/.eslintrc.json
#	packages/node/src/plugins/FederationModuleInfoRuntimeModule.ts
#	packages/node/src/plugins/NodeFederationPlugin.parseRemotes.test.js
@github-actions github-actions bot merged commit ef8e403 into main Oct 3, 2023
6 of 8 checks passed
@github-actions github-actions bot deleted the node-sync-bytedance branch October 3, 2023 01:33
@github-actions
Copy link
Contributor

🎉 This PR is included in version 8.1.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This PR is included in version 3.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

github-actions bot commented Nov 6, 2023

🎉 This PR is included in version 2.1.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

github-actions bot commented Nov 6, 2023

🎉 This PR is included in version 1.0.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

🎉 This PR is included in version 1.0.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

🎉 This PR is included in version 1.0.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants