This repository was archived by the owner on Oct 4, 2026. It is now read-only.
Repository navigation
webpack_server: regenerate the package manifest PnP removed - #20
Merged
Merged
Conversation
`nodejs_binary` used to write a CommonJS package manifest and export it as
`NODE_PACKAGE_MANIFEST`; the Yarn PnP migration dropped both. The webpack dev
server shim still reads that variable, so every `webpack_server` binary now
dies at startup:
Error: Unsupported path type: undefined
at NodePathFS.readFileSync (...pnp.cjs)
at Object.<anonymous> (webpack/server/src/index.js:17)
The manifest is not vestigial. PnP resolves the dev server's own `require`s,
but webpack *bundles* files out of that tree -- its hot client, and the
entries plugins such as @pmmmwh/react-refresh-webpack-plugin inject -- and
webpack resolves their imports from the filesystem, where PnP materializes
nothing. Without the fs-linker view, `webpack/hot/emitter.js` cannot resolve
`events` and `ReactRefreshEntry.js` cannot resolve `core-js-pure`.
webpack-dev-server's `isInstalled` walk for webpack-cli fails the same way.
So `webpack_server` generates the manifest itself, from the CommonJS graph
`nodejs_binary` now forwards -- carried through `WebpackInfo` so it is built in
the binary's own configuration, which a plain `cfg = "exec"` attribute would
not match (`nodejs_transition` sets `//javascript:module`).
Verified against redo's `//redo/shopify/extension:server`: the dev server
starts, compiles with no unresolved modules, and serves a 6.1 MB `main.js`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
97e3e9b(Use Yarn PnP fornodejs_binary) dropped the CommonJS package manifest and theNODE_PACKAGE_MANIFESTexport fromnodejs/runner.sh.tpl.webpack/server/src/index.tsstill reads that variable, so everywebpack_serverbinary dies at startup:(
fs.readFileSync(undefined, "utf8"), via PnP's patchedfs.)Why the manifest is not vestigial
PnP resolves the dev server's own
requires, so the obvious fix — deleting the manifest read — looked right. It isn't. The dev server bundles files out of the tool tree, and webpack resolves their imports from the filesystem, where PnP materializes nothing. Removing the fs-linker view instead produces:and, before that,
webpack-dev-server'sisInstallednode_moduleswalk fails, so it prompts toyarn add -D webpack-cli. (webpack/runtimeonly fakesprocess.versions.pnpfor webpack's owncheckPackageExists, not for the dev server'sisInstalled.)Fix
webpack_servergenerates the manifest itself instead of borrowingnodejs_binary's.It needs the server binary's CommonJS graph in the binary's own configuration — a plain
cfg = "exec"attribute would not match, becausenodejs_binary'sdepgoes throughnodejs_transition(//javascript:module = "node"), and mismatched paths would make the manifest point at files that are not in runfiles. Sonodejs_binaryforwards its dep'sCjsInfo,WebpackInfocarries it asserver_cjs, and_webpack_server_implrunsgen_manifestover it withto_rlocation_pathpackage paths — the same shapenodejs_binaryused to emit.webpack/server-runner.sh.tplexportsNODE_PACKAGE_MANIFESTfrom it; the shim is unchanged.Verification
Against redo at the
4b6fe19pin, carrying this as anarchive_overridepatch:bazel run //redo/shopify/extension:server— starts,webpack 5.94.0 compiled successfully, no unresolved modules, servesmain.jswith HTTP 200 / 6,132,734 bytes.webpack_server,webpack_bundle, andnodejs_binarytarget in redo builds.Before the fix, the same target crashed on
NODE_PACKAGE_MANIFESTat startup.