Skip to content

Commit

Permalink
fix: remove 'use strict'; from systemjs when strict=false (#3101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Beknar Askarov authored and lukastaegert committed Sep 8, 2019
1 parent 8dceaf6 commit 1d524f2
Show file tree
Hide file tree
Showing 11 changed files with 439 additions and 679 deletions.
1,005 changes: 336 additions & 669 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -64,7 +64,7 @@
"homepage": "https://github.com/rollup/rollup",
"dependencies": {
"@types/estree": "0.0.39",
"@types/node": "^12.7.2",
"@types/node": "^12.7.4",
"acorn": "^7.0.0"
},
"devDependencies": {
Expand All @@ -83,15 +83,15 @@
"date-time": "^3.1.0",
"es5-shim": "^4.5.13",
"es6-shim": "^0.35.5",
"eslint": "^6.2.1",
"eslint": "^6.3.0",
"eslint-plugin-import": "^2.18.2",
"execa": "^2.0.4",
"fixturify": "^1.2.0",
"hash.js": "^1.1.7",
"husky": "^3.0.4",
"husky": "^3.0.5",
"immutable": "^4.0.0-rc.12",
"is-reference": "^1.1.3",
"lint-staged": "^9.2.3",
"lint-staged": "^9.2.5",
"locate-character": "^2.0.5",
"magic-string": "^0.25.3",
"markdownlint-cli": "^0.18.0",
Expand All @@ -104,10 +104,10 @@
"pretty-ms": "^5.0.0",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^1.20.1",
"rollup": "^1.20.3",
"rollup-plugin-alias": "^2.0.0",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-license": "^0.12.1",
"rollup-plugin-node-resolve": "^5.2.0",
Expand All @@ -122,12 +122,12 @@
"source-map": "^0.6.1",
"source-map-support": "^0.5.13",
"sourcemap-codec": "^1.4.6",
"systemjs": "^5.0.0",
"terser": "^4.2.0",
"systemjs": "^6.0.0",
"terser": "^4.3.0",
"tslib": "^1.10.0",
"tslint": "^5.19.0",
"turbocolor": "^2.6.1",
"typescript": "^3.5.3",
"typescript": "^3.6.2",
"url-parse": "^1.4.7"
},
"files": [
Expand Down
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);
}

0 comments on commit 1d524f2

Please sign in to comment.