diff --git a/examples/simple.html b/examples/simple.html index dc4a6d7..7c63e59 100644 --- a/examples/simple.html +++ b/examples/simple.html @@ -1,6 +1,6 @@
- +

Realm Shim

diff --git a/package.json b/package.json index a13ef90..c22fad0 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "prettier": "^1.18.2", "rollup": "^1.21.4", "rollup-plugin-babel-minify": "^9.1.0", - "rollup-plugin-strip-code": "^0.2.7", "sinon": "^7.5.0", "tape": "^4.11.0" }, diff --git a/rollup.config.js b/rollup.config.js index 1d540e1..d98ad42 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,5 +1,4 @@ import minify from 'rollup-plugin-babel-minify'; -import stripCode from 'rollup-plugin-strip-code'; export default () => { const isProduction = process.env.NODE_ENV === 'production'; @@ -19,12 +18,7 @@ export default () => { } ]; - const plugins = [ - stripCode({ - start_comment: 'START_TESTS_ONLY', - end_comment: 'END_TESTS_ONLY' - }) - ]; + const plugins = []; if (isProduction) { plugins.push( @@ -45,4 +39,4 @@ export default () => { output, plugins }; -} +}; diff --git a/src/repair/functions.js b/src/repair/functions.js index 9044a03..4a75982 100644 --- a/src/repair/functions.js +++ b/src/repair/functions.js @@ -18,7 +18,6 @@ */ // todo: this file should be moved out to a separate repo and npm module. -const globalEval = eval; export function repairFunctions() { const { defineProperties, getPrototypeOf, setPrototypeOf } = Object; @@ -35,7 +34,7 @@ export function repairFunctions() { let FunctionInstance; try { // eslint-disable-next-line no-new-func - FunctionInstance = globalEval(declaration); + FunctionInstance = (0, eval)(declaration); } catch (e) { if (e instanceof SyntaxError) { // Prevent failure on platforms where async and/or generators diff --git a/src/unsafeRec.js b/src/unsafeRec.js index 970ac60..4c05b18 100644 --- a/src/unsafeRec.js +++ b/src/unsafeRec.js @@ -94,7 +94,7 @@ const repairAccessorsShim = cleanupSource( `"use strict"; (${repairAccessors})();` ); const repairFunctionsShim = cleanupSource( - `"use strict"; const globalEval = eval; (${repairFunctions})();` + `"use strict"; (${repairFunctions})();` ); // Create a new unsafeRec from a brand new context, with new intrinsics and a diff --git a/src/utilities.js b/src/utilities.js index 085c5bc..99c8955 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -29,14 +29,11 @@ export function assert(condition, message) { // Remove code modifications. export function cleanupSource(src) { - /* START_TESTS_ONLY */ - // Restore eval which is modified by esm module. src = src.replace(/\(0,[^)]+\)/g, '(0, eval)'); // Remove code coverage which is injected by nyc module. src = src.replace(/cov_[^+]+\+\+[;,]/g, ''); - /* END_TESTS_ONLY */ return src; }