-
-
Notifications
You must be signed in to change notification settings - Fork 215
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: support node esmodule and mf-manifest esmodule (#2934) #3013
Conversation
Co-authored-by: 张洪恩 <zhanghongen@bwcj.com> Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com>
|
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
# Conflicts: # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Here is a concise summary of the pull request:
This pull request adds support for importing remote files in ESM format in the Node.js environment. The key changes include:
- Updating the
type
property of themoduleInfo
object to use theremoteInfo.type
value, allowing for more flexible handling of different module types (global or esmodule). - Introducing a new
type
property to theremoteInfo
object, which is then passed to theloadScriptNode
function to handle ESM-formatted remote entries. - Updating the script type to 'module' if the provided attributes indicate an ESM format, and adding the ability to apply custom attributes to the created script element.
- Adding a new
loadModule
function to handle the loading and evaluation of ESM modules, and updating thecreateScriptNode
function to support ESM scripts by leveraging theloadModule
function. - Introducing a conditional statement that sets the
ssrRemoteEntryType
property based on thetype
field of thessrRemoteEntry
object, allowing for both CommonJS and ESM formats to be handled.
These changes improve the flexibility and functionality of the module federation runtime, enabling support for ESM-formatted remote files in the Node.js environment.
File Summaries
File | Summary |
---|---|
packages/runtime/src/plugins/generate-preload-assets.ts | The code changes introduce support for importing remote files in esm format in the node environment. The primary modification is updating the type property of the moduleInfo object to use the remoteInfo.type value, which can be either 'global' or 'esmodule', allowing for more flexible handling of different module types. |
packages/runtime/src/utils/load.ts | The code changes introduce support for importing remote files in ESM format in the Node.js environment. The key modifications include adding a new type property to the remoteInfo object, which is then passed to the loadScriptNode function, allowing it to handle ESM-formatted remote entries. |
packages/sdk/src/dom.ts | The code changes introduce support for importing remote files in ESM format in the Node environment. The key modifications include updating the script type to 'module' if the provided attributes indicate an ESM format, and adding the ability to apply custom attributes to the created script element. |
packages/sdk/src/generateSnapshotFromManifest.ts | The code changes introduce support for importing remote files in ESM format in the Node.js environment. The primary modification is the addition of a conditional statement that sets the ssrRemoteEntryType property based on the type field of the ssrRemoteEntry object, allowing for both CommonJS and ESM formats to be handled. |
packages/sdk/src/node.ts | The code changes introduce support for importing remote files in ESM format in the Node.js environment. The primary modifications include adding a new function loadModule that handles the loading and evaluation of ESM modules, and updating the createScriptNode function to support ESM scripts by leveraging the loadModule function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incremental Review
Comments posted: 7
Configuration
Squadron Mode: essential
Commits Reviewed
64c98f1384aed95f9a7d6efe8c9ddf7db2bde4bc...f26ad72e03de69e9b9795fb07614865dfb71e61c
Files Reviewed
- packages/runtime/src/plugins/generate-preload-assets.ts
- packages/runtime/src/utils/load.ts
- packages/sdk/src/dom.ts
- packages/sdk/src/generateSnapshotFromManifest.ts
- packages/sdk/src/node.ts
Files Ignored
These files were ignored due to the filter in the squadron.yaml file.
- .github/workflows/release.yml
- package.json
- pnpm-lock.yaml
Description
Supports importing remote files in esm format in the node environment
Related Issue
module-federation/vite#73
Types of changes
Checklist