馃悶 bug report
Affected Rule
nodejs_binary / nodejs_test
Is this a regression?
Yes, 4.4.1 works fine, but 4.4.2 and 4.4.3 are broken. This is likely related to the linker refactor.
Description
When a package is symlinked under node_modules due to, for example, the packge_name attribute of js_library, then node modules will be loaded from a different directory.
I noticed this with react, which complains when multiple instances are loaded.
We can see the problem from the following (edited) stack trace:
<snip>
at useMemo (node_modules/repro/node_modules/react/cjs/react.development.js:1531:20)
at Component (../component/component.tsx:4:12)
<snip>
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1042:14)
<snip>
at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)
Notice how we first load react from node_modules/react-dom, and later from node_modules/repro/node_modules.
The component package contains the following rule:
js_library(
name = "component",
package_name = "repro/component",
visibility = ["//visibility:public"],
deps = ["component-ts"],
)
Omitting the workspace name (repro) from the package_name seems to solve the problem (i.e., changing it to "component" or "blah/component").
馃敩 Minimal Reproduction
I committed a reproduction here.
馃敟 Exception or Error
In this case, react complains and the test fails.
馃實 Your Environment
Operating System:
Output of bazel version:
Rules_nodejs version:
馃悶 bug report
Affected Rule
nodejs_binary/nodejs_testIs this a regression?
Yes, 4.4.1 works fine, but 4.4.2 and 4.4.3 are broken. This is likely related to the linker refactor.
Description
When a package is symlinked under node_modules due to, for example, the
packge_nameattribute ofjs_library, then node modules will be loaded from a different directory.I noticed this with react, which complains when multiple instances are loaded.
We can see the problem from the following (edited) stack trace:
Notice how we first load react from
node_modules/react-dom, and later fromnode_modules/repro/node_modules.The component package contains the following rule:
Omitting the workspace name (repro) from the package_name seems to solve the problem (i.e., changing it to "component" or "blah/component").
馃敩 Minimal Reproduction
I committed a reproduction here.
馃敟 Exception or Error
In this case, react complains and the test fails.
馃實 Your Environment
Operating System:
Output of
bazel version:Rules_nodejs version: