-
-
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
question: why not strict mode in compiled output? #2098
Comments
I’m not sure if it’s about saving the bytes for @guybedford do you have thoughts? |
Yes exactly those bytes are deemed unnecessary :) |
@frehner could you explain how strict mode / not strict mode impacts things and how you even noticed? |
I came across it as I was debugging something else. In the end, it turned out that it was because my code wasn't being executed in strict mode. However, I think there may still be some value in having systemjs itself execute in strict mode: when it's in non-strict mode (aka sloppy mode) there is the extremely small but still possible chance that there's an error that would throw in strict mode, but since it's in sloppy mode, it would fail silently. Those types of situations would be extremely hard for users of SystemJS to debug properly. |
I support turning on strict mode - I think a better error message (that only rarely shows) is worth the 10 bytes. |
SystemJS itself not running in strict mode doesn't affect code it evaluates executing in strict mode. Whenever converting modules to SystemJS module format, the If that is missing, that is a bug in the transpiler outputting the System format. |
From my testing, I think systemjs bring in strict mode does actually affect things. But I could be wrong here. This fails silently, even though it was called in strict mode. This would be similar to calling SystemJS functions from my own code, correct? // fails silently, even though sloppy() is called from a location where strict mode is active
function sloppy() {
myGlobal = 5
}
(function() {
"use strict";
sloppy()
})() And just for reference: this throws an error, even though it was called in sloppy mode // throws an error, even though strict() is called from a location where sloppy mode is active
function strict() {
"use strict";
myGlobal = 5
}
(function() {
strict()
})() so even if I call systemjs functions in strict mode, whatever systemjs itself does appear to depend on whether it itself is in strict mode. If I'm reading and interpreting this correctly. |
updated the above comment now that I'm at a computer. |
Just had a report that systemjs fails to work in older versions of chrome (v45) due to this. The error:
|
@frehner can you share your SystemJS module output here? It should look like - System.register([..], function (...) {
'use strict';
// ...
}); if the Alternatively if using AMD or globals you would also get an error like this. |
It may have actually been an issue in single-spa itself. We just corrected it in this PR single-spa/single-spa#507 (comment) |
It's true that single-spa was not in strict mode, but that would not cause the error I think that this is a problem with SystemJS - that's what the person reporting the issue indicated. SystemJS currently doesn't work in certain older versions of Chrome due to its use of I think the fix is to enable strict mode, even though it incurs about 10 bytes to the bundles. |
Ahh I didn't realise |
(kind of odd to have IE11 support but not Chrome 45!) |
This was resolved in #2162. |
Not really an issue, more of a question:
is there a reason that strict mode is explicitly turned off in the compiled output?
https://github.com/systemjs/systemjs/blob/master/rollup.config.js#L11
I just tested it with strict mode on, and all the tests continue to pass. So it doesn't appear (on the surface) to have to do with features you're building or anything.
Anyway, just curious.
The text was updated successfully, but these errors were encountered: