-
-
Notifications
You must be signed in to change notification settings - Fork 374
fix(esbuild): fix esbuild 0.25.0 compatibility and remote module loading #4255
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 3793678 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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. |
- Use esbuild context() API for watch mode (0.25.0 removed watch option) - Enables proper build and watch functionality in apps/esbuild demo 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
41b3cea to
57b0f91
Compare
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.
Pull request overview
This pull request addresses two critical issues in the esbuild integration: compatibility with esbuild 0.25.0's API changes and fixing remote module resolution to use runtime loading instead of import maps.
Key Changes:
- Updated build script to use esbuild's
context()API for watch mode instead of the deprecatedwatchoption - Refactored remote module loading to use
container.loadRemote()at runtime instead of relying on import maps
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
apps/esbuild/build/build-common.js |
Updated to use esbuild 0.25.0's context() API for watch mode, replacing the deprecated watch option in the build() call |
packages/esbuild/src/adapters/lib/linkRemotesPlugin.ts |
Refactored virtual module generation to use runtime loadRemote() instead of import maps, removed obsolete federationRemote/ resolution handler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The import map registration was failing because: 1. The runtimePlugin was looking for moduleMap in the host scope instead of fetching it from the remote module exports 2. The import map key was using the host name instead of the remote name 3. The async registration in runtimePlugin.init() ran after bootstrap imports This fix adds explicit synchronous import map registration in the host initialization code that runs after initializeSharing but before any code that imports from remotes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Summary
Fixed two critical issues preventing the
apps/esbuilddemo from working:1. esbuild 0.25.0 Watch Mode Compatibility
apps/esbuild/build/build-common.jswatchoption frombuild()APIesbuild.context()withctx.watch()for watch mode instead of passingwatchoption tobuild()2. Import Map Registration for ESM Remote Modules
packages/esbuild/src/adapters/lib/containerReference.tsmfe1/component) were failing with "Unable to resolve specifier" errorruntimePlugin.init()was looking formoduleMapin the host scope instead of fetching it from the remote module exportsruntimePlugin.init()ran after bootstrap imports needed theminitializeSharingbut before any code that imports from remotes. This ensures import maps are registered before es-module-shims tries to resolve remote module specifiers.Test Plan
pnpm nx run esbuild:buildcd apps/esbuild && pnpm run buildpnpm run start:remoteandpnpm run start:hostTypes of Changes
🤖 Generated with Claude Code