What happened?
When bundling a npm package with package.json field browsers where it includes a filepath key mapped to false, rules_esbuild fails to build, but calling through pnpm succeeds. See repro linked below with a failure case, successful case, and a workaround where I disabled the esbuild sandbox plugin. The browser field is used to publish an isomorphic package that can operate both in node and browser environments. It can map some file that uses node apis to either another file that includes a replacement interface implementation or chooses to simply not include a replacement (which is what happens in this case).
See this npm package where I encountered this issue https://app.unpkg.com/@loaders.gl/worker-utils@3.4.15/files/package.json#L40
The error looks like:
✘ [ERROR] Could not read from file: /home/user/.cache/bazel/_bazel_user/b97476d719d716accead0f2d5b93104f/sandbox/processwrapper-sandbox/1753/execroot/__main__/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@loaders.gl+worker-utils@3.4.15/node_modules/@loaders.gl/worker-utils/dist/esm/lib/process-utils/child-process-proxy
node_modules/.aspect_rules_js/@loaders.gl+worker-utils@3.4.15/node_modules/@loaders.gl/worker-utils/dist/esm/index.js:16:45:
16 │ ...hildProcessProxy } from './lib/process-utils/child-process-proxy';
The package.json file looks like:
{
"browser": {
"./dist/esm/lib/process-utils/child-process-proxy.js": false
},
}
Ideally, rules_esbuild behaves in the same as esbuild through pnpm.
Version
Development (host) and target OS/architectures: Reproducible on Linux+Arm and Mac+Arm
Output of bazel --version: 8.1.1
Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: Reproducible on 0.21.0 and latest 0.22.1
Language(s) and/or frameworks involved:
How to reproduce
See repro code and instructions here https://github.com/chasestarr/bazel-js/tree/main/src/esbuild-entrypoint-browser-field-false
Any other information?
No response
What happened?
When bundling a npm package with package.json field
browserswhere it includes a filepath key mapped tofalse,rules_esbuildfails to build, but calling throughpnpmsucceeds. See repro linked below with a failure case, successful case, and a workaround where I disabled the esbuild sandbox plugin. The browser field is used to publish an isomorphic package that can operate both in node and browser environments. It can map some file that uses node apis to either another file that includes a replacement interface implementation or chooses to simply not include a replacement (which is what happens in this case).See this npm package where I encountered this issue https://app.unpkg.com/@loaders.gl/worker-utils@3.4.15/files/package.json#L40
The error looks like:
The
package.jsonfile looks like:Ideally,
rules_esbuildbehaves in the same asesbuildthroughpnpm.Version
Development (host) and target OS/architectures: Reproducible on Linux+Arm and Mac+Arm
Output of
bazel --version: 8.1.1Version of the Aspect rules, or other relevant rules from your
WORKSPACEorMODULE.bazelfile: Reproducible on 0.21.0 and latest 0.22.1Language(s) and/or frameworks involved:
How to reproduce
See repro code and instructions here https://github.com/chasestarr/bazel-js/tree/main/src/esbuild-entrypoint-browser-field-false
Any other information?
No response