Skip to content
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

fix: remove 'use strict'; from systemjs when strict=false #3101

Merged
merged 2 commits into from Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/finalisers/system.ts
Expand Up @@ -173,7 +173,7 @@ export default function system(
let wrapperStart =
`System.register(${registeredName}[` +
dependencyIds.join(`,${_}`) +
`],${_}function${_}(${wrapperParams})${_}{${n}${t}'use strict';` +
`],${_}function${_}(${wrapperParams})${_}{${n}${t}${options.strict ? "'use strict';" : ''}` +
getStarExcludesBlock(starExcludes, varOrConst, _, t, n) +
getImportBindingsBlock(importBindings, _, t, n) +
`${n}${t}return${_}{${
Expand Down
8 changes: 8 additions & 0 deletions test/form/samples/strict-false/_config.js
@@ -0,0 +1,8 @@
module.exports = {
description: 'use strict should not be present',
options: {
output: {
strict: false
}
}
};
13 changes: 13 additions & 0 deletions test/form/samples/strict-false/_expected/amd.js
@@ -0,0 +1,13 @@
define(function () {

const localVariable = 'local';

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}

});
9 changes: 9 additions & 0 deletions test/form/samples/strict-false/_expected/cjs.js
@@ -0,0 +1,9 @@
const localVariable = 'local';

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}
9 changes: 9 additions & 0 deletions test/form/samples/strict-false/_expected/es.js
@@ -0,0 +1,9 @@
const localVariable = 'local';

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}
12 changes: 12 additions & 0 deletions test/form/samples/strict-false/_expected/iife.js
@@ -0,0 +1,12 @@
(function () {
const localVariable = 'local';

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}

}());
18 changes: 18 additions & 0 deletions test/form/samples/strict-false/_expected/system.js
@@ -0,0 +1,18 @@
System.register([], function () {

return {
execute: function () {

const localVariable = 'local';

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}

}
};
});
15 changes: 15 additions & 0 deletions test/form/samples/strict-false/_expected/umd.js
@@ -0,0 +1,15 @@
(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(function () {
const localVariable = 'local';

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}

}));
9 changes: 9 additions & 0 deletions test/form/samples/strict-false/main.js
@@ -0,0 +1,9 @@
const localVariable = 'local'

try {
globalVariable = localVariable;
} catch (error) {
console.log('use strict; detected', error);

Function("g", "globalVariable = g")(localVariable);
}