-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Conditional assignments to exports should not mark a js file as a commonjs module #33765
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
Comments
I definitely thought there was some |
Related: playing around with this in VS Code, I get this in the console:
😦 |
Is it the fact that it’s conditional, or the fact that |
Right, exactly - there's a few conditions I think we need to fix.
|
This seems like a good idea, but would be a breaking change... hopefully not too many users would be affected by it, but I think that part should probably wait for 3.8. |
Counterpoint: Bundler-packed code is often more complex than a simple IIFE: aframe/dist/aframe-master.js is a good example. |
Countercounterpoint: bundler-packed code usually is bundling multiple modules, not all of which's exports are top-level and visible to consumers. |
The 3.7 part of this was done in #33784. The remaining bit is a breaking change so I’m moving the milestone to 3.8. |
Tried this in #34805, and it turns out we have a number of tests that assert that we should scan for export assignments all over the place. This is JavaScript, after all, so I would wager that users would rather us just trust them that their nested exports are legitimate. Let’s keep the existing behavior until/unless it causes a problem and people ask for something different. |
The addition of element accesses on
exports
broke theuglify-js
user suite test. This is a minimal repro:Code
Expected behavior:
file1.js
is treated as a globally scoped file andref.js
typechecks.Actual behavior:
Err in
ref.js
, no referenced found toGlobalThing
infile1.js
becausefile1.js
is treated like a module.cc @sandersn @andrewbranch While this error only appeared once we started to recognize element access export assignments (even if we can't bind them because they're computed names, for some reason), that we flag a reference to a variable named
exports
within a function body (and a conditional!) as a module also seems questionable.The text was updated successfully, but these errors were encountered: