diff --git a/changelog.d/fixes/9633-npm-build-files.md b/changelog.d/fixes/9633-npm-build-files.md new file mode 100644 index 0000000000..c1dc5128da --- /dev/null +++ b/changelog.d/fixes/9633-npm-build-files.md @@ -0,0 +1 @@ +- fix(build): add build-next-isolated.mjs sibling imports to package.json files array diff --git a/package.json b/package.json index ba0b667569..b1430ec223 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,11 @@ "scripts/dev/tls-options.mjs", "scripts/check/check-supported-node-runtime.ts", "scripts/dev/sync-env.mjs", - "scripts/build/native-binary-compat.mjs", + "scripts/build/assembleStandalone.mjs", + "scripts/build/backendOnlyPages.mjs", "scripts/build/build-next-isolated.mjs", + "scripts/build/build-tproxy-native.mjs", + "scripts/build/native-binary-compat.mjs", "scripts/build/runtime-env.mjs", "README.md", "LICENSE", diff --git a/tests/unit/repro-9633.test.ts b/tests/unit/repro-9633.test.ts new file mode 100644 index 0000000000..7acb750e5a --- /dev/null +++ b/tests/unit/repro-9633.test.ts @@ -0,0 +1,27 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; + +const pkg = JSON.parse(readFileSync("package.json", "utf-8")); +const files = pkg.files || []; + +// #9633: `build-next-isolated.mjs` is published (fixed in #1126), but three of +// its sibling modules it imports were missing from the `files` whitelist, so +// `npm run build` on a globally-installed package crashed with ERR_MODULE_NOT_FOUND. +// The dynamic import of `build-tproxy-native.mjs` (~line 308) and the static +// imports of `assembleStandalone.mjs` / `backendOnlyPages.mjs` must ship too. +const NEEDED = [ + "scripts/build/assembleStandalone.mjs", + "scripts/build/backendOnlyPages.mjs", + "scripts/build/build-tproxy-native.mjs", + "scripts/build/colocateOptionals.mjs", +]; + +test("#9633: build-next-isolated.mjs sibling imports present in package.json files[]", () => { + for (const needed of NEEDED) { + assert.ok( + files.some((f) => typeof f === "string" && f === needed), + `${needed} is not in package.json files[]` + ); + } +});