Skip to content

Commit

Permalink
fixup global context handling
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 21, 2018
1 parent f0930b1 commit 55b09a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ module.exports = (
assets[filename + '.map'] = map;
code = `const { readFileSync } = require('fs'), { Script } = require('vm');\n` +
`const source = readFileSync(__dirname + '/${filename}.cache.js').toString(), cachedData = readFileSync(__dirname + '/${filename}.cache');\n` +
`new Script(source, { cachedData }).runInNewContext(Object.assign({}, global, { console, module, exports, require, __filename, __dirname }));\n`;
`const context = Object.create(null); for (const key of Reflect.ownKeys(global)) context[key] = global[key];\n` +
`new Script(source, { cachedData }).runInNewContext(Object.assign(context, { module, exports, require, __filename, __dirname }));\n`;
if (map) map = {};
}

Expand Down

0 comments on commit 55b09a4

Please sign in to comment.