-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Emit modules in strict mode #5765
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
Emit modules in strict mode #5765
Conversation
it is common for users to have "use strict" as their first line in a module anyways, now we will emit two. |
Correct! But this change would bring us inline with both babel and our own parser (since we parse in strict mode in modules). There's also no harm in it. (And users can easily remove the extra |
An interesting behavioral quirk this fixes is this: export function what() {
return this;
}
var x = what.call(2);
assert(typeof x === "number"); That assertion changes truthiness based on the strict mode status of the containing code. (Specifically, its only true in strict mode.) |
You could just check if the first statement is a |
@DanielRosenwasser So you have asked, so you shall recieve |
Look good 👍 Could you add a test when users already have "use strict" and we omit the emitting. |
💯 |
@yuit |
@weswigham can you add a blurb about this change and what breaks in the breaking changes page; mainly issues that the compiler will not catch but will break at runtime, e.g. eval introducing new variables, value of |
Fixes #3576.
Closes #4963.