You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And assuming that the transpilation of src.ts makes an ESM bundle in bazel-dist, running the js_binary fails because the generated src.js file is neither src.mjs, nor does Node know to run as "type": "module".
In other words, bazel run //src:src_bin will fail:
(node:92736) Warning: To load an ES module, set"type": "module"in the package.json or use the .mjs extension.
However, if in the source tree I update the package.json file to have "type": "module", the js_binary will now run.
I'm not sure if this is a bug or a question, but I'm surprised that a change to the package.json file in the source tree affects the js_binary. I assumed (perhaps incorrectly) that there would be a sandbox for the node process underpinning js_binary, and that it wouldn't have access to a package.json in the source tree.
Am I missing something?
The text was updated successfully, but these errors were encountered:
Assuming something like this in a
BUILD
file:And assuming that the transpilation of
src.ts
makes an ESM bundle inbazel-dist
, running thejs_binary
fails because the generatedsrc.js
file is neithersrc.mjs
, nor does Node know to run as"type": "module"
.In other words,
bazel run //src:src_bin
will fail:However, if in the source tree I update the
package.json
file to have"type": "module"
, thejs_binary
will now run.I'm not sure if this is a bug or a question, but I'm surprised that a change to the
package.json
file in the source tree affects thejs_binary
. I assumed (perhaps incorrectly) that there would be a sandbox for the node process underpinningjs_binary
, and that it wouldn't have access to apackage.json
in the source tree.Am I missing something?
The text was updated successfully, but these errors were encountered: