Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
Ugly workaround for issue nodejs/node#7593
Browse files Browse the repository at this point in the history
Copy executionContext into global variable. This is ugly, because it
means that identically-named properties of different execution contexts
can step on each other in subsequent calls to model.prepare. This is
ok-ish, because SCION support for node --inspect is a development-only
feature. This will not affect production uses of SCION.

One day I may patch require to accept an executionContext argument, and
use vm.runInContext inside of Module._compile.
  • Loading branch information
jbeard4 committed Aug 9, 2017
1 parent 0e95cd3 commit ab54372
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/compiler/scjson-to-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,14 @@ SCJsonRawModule.prototype.prepare = function(cb, executionContext, hostContext){
//console.log('modulePath ', modulePath );
fs.writeFile(modulePath, generatedCode, function(err){
if (err) return cb(err);
//Copy the execution context into the global context.
//This is terrible, but seems to be the most reliable way to get --inspect support working with source maps and chrome for node v7.
//Support for --inspect is still pretty unstable.
//Fortunately, this code will only be used in development.
//One day I may patch require so that it takes an executionContext argument.
Object.keys(executionContext).forEach( (k) => {
global[k] = executionContext[k];
});
var fnModel = require(modulePath);
cb(null, fnModel);
});
Expand Down

0 comments on commit ab54372

Please sign in to comment.