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.