From 07a582716bda4b5e8b67a1c4b0a39363ce15f60d Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Wed, 7 Oct 2026 17:42:48 +0530 Subject: [PATCH 1/2] Build: Keep absolute paths out of worker source maps The `wpWorkers` module redirect replaced a file such as `wasm-vips/lib/vips-es6.js` with `export { default } from ""`. esbuild embeds that generated module in `sourcesContent`, so every published `@wordpress/vips` source map carried the build machine's checkout path (`/home/runner/work/gutenberg/gutenberg/publish/...` on npm today), and two builds of the same commit from different directories produced different tarballs. Emit a specifier relative to the redirected file and pass `resolveDir`, so esbuild still resolves the same target while the output stays independent of where the repository is checked out. --- packages/wp-build/CHANGELOG.md | 1 + packages/wp-build/lib/worker-build.mjs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/wp-build/CHANGELOG.md b/packages/wp-build/CHANGELOG.md index f2f36d1e9ef236..d6c84db2157e41 100644 --- a/packages/wp-build/CHANGELOG.md +++ b/packages/wp-build/CHANGELOG.md @@ -5,6 +5,7 @@ ### Bug Fixes - Add the `@babel/core` dependency, a peer of `esbuild-plugin-babel` ([#83765](https://github.com/WordPress/gutenberg/pull/83765)). +- Keep the build machine's absolute paths out of worker source maps when `wpWorkers` redirects a module with `resolve`, so the output is reproducible across checkouts. ### Internal diff --git a/packages/wp-build/lib/worker-build.mjs b/packages/wp-build/lib/worker-build.mjs index a820a11525bc52..696c2db4123c49 100644 --- a/packages/wp-build/lib/worker-build.mjs +++ b/packages/wp-build/lib/worker-build.mjs @@ -55,11 +55,20 @@ function createModuleRedirectPlugin( resolveMap ) { matchedKey, resolveMap[ matchedKey ] ); + const resolveDir = path.dirname( args.path ); + // A relative specifier keeps the checkout path out of the source map. + const specifier = + './' + + path + .relative( resolveDir, targetPath ) + .split( path.sep ) + .join( '/' ); return { contents: `export { default } from ${ JSON.stringify( - targetPath + specifier ) };`, loader: 'js', + resolveDir, }; } ); }, From 880aa650e40def5f3b6a8f7dfd95eed634d3ba03 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Wed, 7 Oct 2026 18:06:44 +0530 Subject: [PATCH 2/2] Build: Link the changelog entry to its PR --- packages/wp-build/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wp-build/CHANGELOG.md b/packages/wp-build/CHANGELOG.md index d6c84db2157e41..cc642577b5624a 100644 --- a/packages/wp-build/CHANGELOG.md +++ b/packages/wp-build/CHANGELOG.md @@ -5,7 +5,7 @@ ### Bug Fixes - Add the `@babel/core` dependency, a peer of `esbuild-plugin-babel` ([#83765](https://github.com/WordPress/gutenberg/pull/83765)). -- Keep the build machine's absolute paths out of worker source maps when `wpWorkers` redirects a module with `resolve`, so the output is reproducible across checkouts. +- Keep the build machine's absolute paths out of worker source maps when `wpWorkers` redirects a module with `resolve`, so the output is reproducible across checkouts ([#84163](https://github.com/WordPress/gutenberg/pull/84163)). ### Internal