-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support for importing reserved JS words #1091
Conversation
Oh, I see... I've forgotten to put Update. Forgot to recompile the target before running |
@Pauan, so I think we want to add everything from this list of global objects, don't we? We should be consistent with adding such things as Update. Oh, won't do, it breaks everything global we generate bindings for :) Added only the value properties and |
@mvlabat https://tc39.github.io/ecma262/#sec-identifiers-static-semantics-early-errors You can verify this by attempting to use the following JS code: import { arguments, eval } from "foo"; You will get a SyntaxError. As for globals (including |
@Pauan alright, got it. And fixed |
@Pauan Ahh.. And it seems like we need some kind of special treatment for |
@mvlabat I think the logic should be something like "if this identifier was imported, then mangle it, otherwise don't". It would need to run on every identifier, not just the imported identifiers. |
@Pauan But it has to be mangled only on I'm not sure I understand this case correctly... If I'm mistaken, could you please explain it with an example? I'll try to reproduce it and come up with a fix then. |
@mvlabat Consider this JS code: import { eval as eval1 } from "foo";
console.log(eval1); As you can see, it needs to mangle it at both the import site and also the use site. Otherwise the use site will still be using Though I guess your |
@Pauan Oh, you meant this case. Yeah, it must work correctly. If I understand it right, import { eval as eval1 } from "foo";
console.log(eval2); And there's nothing my code changed in this respect. |
@alexcrichton, if everything looks ok, can we merge the PR and make a new release? ) If not, I'll surely try to fix it. Still can't use wasm-bindgen built locally with Parcel, and further development of my project is currently blocked without this change. Thank you! |
Thanks for the PR @mvlabat! Instead of using It may also be somewhat overkill to try to add an exhaustive list of keywords here, I suspect basically nothing comes up in practice except "default"? |
Not under normal circumstances, since they're reserved words. The only way to create/access them on the global environment is to use |
I think that
If we want to support this, it's possible, I think. Though it would be a really, really rare case. I'm just not sure if we can return right from
If we want to support only default exports, then I can publish an alternative PR with much fewer lines of code, that handles only that specific case. And I think all the questions above will just become irrelevant ) |
Ok thanks for the info! I'd be curious to see if we could just handle the |
This should fix #1006
Implemented the idea explained in #1006 (comment).
Now
should be glued with
I tested this behaviour on my local example project and it seems to be OK, though I couldn't get it working for the tests and
import_js
example. For some reasonjs_name
attribute for types is just ignored there.