fix(sdk): handle node builtins in ESM remote loader#4816
Conversation
🦋 Changeset detectedLatest commit: ff457b1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 47 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thanks for opening the draft PR. This looks like it may address the issue. Since it is still in draft, we'll wait until you mark it as ready for review, then take a closer look. |
|
@2heal1 Thank you for your response. I’ve marked the PR as ready for review. Please take a look when you have a chance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5fc8b29b22
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/playground
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
Bundle Size Report16 package(s) changed, 26 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 35.70 MB (+53.7 kB (+0.1%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
b77925d to
b14d02a
Compare
84cb48f to
a370d5b
Compare
Description
Handle Node.js built-in module imports in the SDK Node ESM remote loader.
This PR updates the
vm.SourceTextModuleloading path used byloadScriptNode(..., { type: 'module' })so that:node:url,node:module, and bare builtins such aspathare loaded with native Node import and returned to the linker asvm.SyntheticModuleinstances.http:andhttps:module URLs; unsupported non-http specifiers fail with a clear error instead of being routed throughfetch.import.meta.url, which allows patterns such ascreateRequire(import.meta.url).The main issue this PR is meant to address is the
node:*builtin path. Theimport.meta.urland dynamic import pieces are adjacent ESM loader fixes found while covering the same Node ESM remote loader flow. I opened this as a draft so maintainers can confirm whether they prefer keeping those together or splitting them.Related Issue
fixes #4815
Types of changes
Checklist
Test Plan
NODE_OPTIONS=--experimental-vm-modules corepack pnpm --filter @module-federation/sdk testcorepack pnpm --filter @module-federation/sdk run lintcorepack pnpm --filter @module-federation/sdk run buildNote:
buildcompletes successfully, with an existing rolldown warning about the pre-existingeval('require')CJS path inpackages/sdk/src/node.ts.