Skip to content

fix(esbuild): honor absWorkingDir for remote output - #5097

Open
ScriptedAlchemy wants to merge 16 commits into
rfc5036/04-runtime-image-cachefrom
rfc5036/05-esbuild-rollout
Open

ScriptedAlchemy wants to merge 16 commits into
rfc5036/04-runtime-image-cachefrom
rfc5036/05-esbuild-rollout

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Part of RFC #5036. An alternate proposal is open at #5128 with its own stack. This PR stays open until the decision on #5036 is made.
Stack: 5 of 7. Base: #5096 (rfc5036/04-runtime-image-cache). Next: #5098.
Landing order: #5093 → #5094 → #5095 → #5096 → #5097 → #5098 → #5107.

What changes

An esbuild build whose absWorkingDir differs from process.cwd() now rewrites the right remote entry and writes mf-manifest.json to its own output directory. Before, the onEnd rewrite resolved the metafile path from the process directory, and writeRemoteManifest wrote the manifest against process.cwd(). The manifest landed in the wrong place and could leave stray files behind. Other builds keep the same output.

Output paths now come from one absWorkingDir || process.cwd() read at build setup, shared by the remote-entry rewrite and the manifest path. The manifest buildName lookup is unchanged.

This PR does not add condition selection to esbuild. It adds a regression test that the adapter still bundles the full runtime, which the adapter needs until a separate design for package conditions exists.

Verification

  • The branch history was rewritten on 2026-09-26 to remove attribution trailers from commit messages only. Every tree and patch is identical to the verified head; 9f7dc2319 is the rewritten tip.

  • The esbuild package now has a test script. One test runs a temporary producer through the public moduleFederationPlugin and requires container, remote, and shared runtime modules in the emitted graph.

  • A second test builds from a directory outside the repo. It checks that the rewritten remote entry no longer contains the __MODULE_MAP__ placeholder and that mf-manifest.json lands under that build's output directory, not next to the package source. Neither test changes the process directory or adds a custom resolver path.

  • The esbuild build, test, and lint, Prettier, and git diff --check pass. Publint finished with the package's existing export warnings.

  • CI at 9f7dc2319 passed 9 checks, cancelled 4, and skipped 23.

  • The 4 cancelled checks are checkout-install and node20-compat in Build Affected Packages, lint-deps in Lint Dependencies, and publish-preview in pkg.pr.new Preview. Those three workflows each ran twice on this commit. They set cancel-in-progress: true per PR, so the second run cancelled the first about a second after it started. The second run of each workflow passed on the same commit. The cancelled runs were not rerun.

  • 12 skipped checks are the jobs of the cancelled Build Affected Packages run, which wait on checkout-install. The other 11 are the end-to-end suites in the second run, because tools/scripts/ci-is-affected.mjs selected none of them for this diff. No end-to-end suite ran at this head.

Deviations from the RFC

None noted.

Overlaps with open PRs

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@changeset-bot

changeset-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9f7dc23

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@module-federation/esbuild Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@9f7dc23

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@9f7dc23

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@9f7dc23

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@9f7dc23

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@9f7dc23

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@9f7dc23

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@9f7dc23

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@9f7dc23

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@9f7dc23

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@9f7dc23

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@9f7dc23

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@9f7dc23

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@9f7dc23

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@9f7dc23

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@9f7dc23

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@9f7dc23

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@9f7dc23

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@9f7dc23

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@9f7dc23

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@9f7dc23

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@9f7dc23

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@9f7dc23

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@9f7dc23

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@9f7dc23

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@9f7dc23

@module-federation/rstest

pnpm add https://pkg.pr.new/@module-federation/rstest@9f7dc23

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@9f7dc23

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@9f7dc23

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@9f7dc23

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@9f7dc23

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@9f7dc23

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@9f7dc23

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@9f7dc23

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@9f7dc23

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@9f7dc23

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@9f7dc23

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@9f7dc23

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@9f7dc23

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@9f7dc23

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@9f7dc23

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@9f7dc23

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@9f7dc23

commit: 9f7dc23

@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/04-runtime-image-cache branch from 2d87526 to 92b0669 Compare September 18, 2026 15:50
@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/05-esbuild-rollout branch from 57e443d to 012bbb2 Compare September 18, 2026 15:55
@ScriptedAlchemy ScriptedAlchemy changed the title test(esbuild): keep the full runtime contract fix(esbuild): honor absWorkingDir for remote output Sep 18, 2026
@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/04-runtime-image-cache branch from 92b0669 to c919e89 Compare September 18, 2026 16:10
Resolve generated remote-entry files from esbuild's configured working directory.

Test the public adapter without process-directory or resolver overrides.
@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/05-esbuild-rollout branch from 012bbb2 to 18957e7 Compare September 18, 2026 16:10
writeRemoteManifest resolved the host package.json and wrote
mf-manifest.json against process.cwd() instead of esbuild's
absWorkingDir, same bug as the remote-entry rewrite fixed earlier on
this branch. A build run from a different directory than its
absWorkingDir wrote the manifest to the wrong place.

Read absWorkingDir once at build setup and share it through a
resolveFromWorkingDir helper used by the remote-entry rewrite, the
manifest path, and the package.json lookup.

Add a regression test that builds from a temp directory under
os.tmpdir(), outside the package folder, and asserts the remote entry
no longer contains __MODULE_MAP__ and the manifest lands under that
build's own output directory.
The package.json lookup for the manifest build name resolves an absolute
`/package.json` and falls back to the config name, as on main. Reading the
package.json under absWorkingDir would change `buildName` for every build,
so this PR only moves where the manifest is written.

This branch has not been deployed

No deployments
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.

1 participant