-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nodejs_binary prefers ES module exports over CommonJS #1966
Comments
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs! |
The error still happens on
I've updated the reproduction repository accordingly. |
This is ultimately due to #315, I think - the |
@quasicomputational I agree #315 is the root cause. #2125 will make the patching of the |
This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs! |
This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?" |
🐞 bug report
Affected Rule
The issue is caused by the rule:
nodejs_binary
Is this a regression?
No
Description
The
nodejs_binary
rule patches therequire
function of Node.js in a way that tries to load resolve extension-less files as ES module files (.mjs extension) before CommonJS modules (.js extension), even though ES Modules cannot be loaded usingrequire
🔬 Minimal Reproduction
I originally hit this problem on code using the
graphql
library, which exposes both CommonJS and ESM entrypoints so the minimal reproduction case starting fromnpx @bazel/create
is simply ayarn add graphql
and adding anodejs_binary
rule that loads a file doingrequire('graphql')
Repository: https://github.com/leops/bazel_nodejs_esm_repro
🔥 Exception or Error
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_nodejs version:
The text was updated successfully, but these errors were encountered: