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
feat(referencesImport): support named exports accessed via namespace imports #12603
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 191a654:
|
Only took me 3/4 of a year to follow up on the issue 🙈 |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/41471/ |
import * as ns from "some-module";
ns.foo = "foo";
// error: can not reassign "ns"
ns = anotherNs
|
@JLHwung as far as I know, this is not the case? Maybe I'm missing something.
and trying to add one fails with
|
I've checked the spec and these 'module namespace exotic objects' are indeed non-extensible, and their |
Both done - lmk if this needs anything else |
The failing e2e tests are not related, and are probably caused by a slightly old base branch. |
Would you like me to rebase? |
Yes please! |
828dfa0
to
f22c8b5
Compare
Done, it seems this was because it was based off of |
…imports * test(traverse): referencesImport * feat(referencesImport): support named exports accessed via namespace imports * feat(referencesImport): support `namespaceObj?.importName` and `namespaceObj["importName"]` * refactor(referencesImport): simplify member expression computed branches * test(referencesImport): aliased named import case * fix(referencesImport): do not be fooled by import name "*" at least when detecting accessing a named import via a '*' import Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
1b232a5
to
191a654
Compare
See referenced issue (or tests) for explanation/example.
Not really a bug fix because it was unclear how smart
referencesImport
is - this makes it a bit less limited.We could of course go even further, support some cases of computed properties, etc., but I'd argue this is a pretty good line to draw because
ns.dep
is by far the most common way to access a named import via a namespace import object.Don't think I have permission to request reviews here so cc @nicolo-ribaudo 😅