From eb63a85ed623d07a1a6511a17bc5f2701d7f3ded Mon Sep 17 00:00:00 2001 From: guybedford Date: Wed, 26 Aug 2015 19:02:29 +0200 Subject: [PATCH] ensure we match all System._nodeRequire replacements --- compilers/cjs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compilers/cjs.js b/compilers/cjs.js index 060b55b..8ee82f7 100644 --- a/compilers/cjs.js +++ b/compilers/cjs.js @@ -133,8 +133,11 @@ exports.compile = function(load, opts, loader) { var output = compiler.write(tree, load.address); + // replace System._nodeRequire with $__System, ensuring we don't replace an existing $__System if (opts.sfx) - output = output.replace(/System\._nodeRequire/g, '$__System._nodeRequire'); + output = output.replace(/(^|[^_])System\._nodeRequire/g, function(match, startArg) { + return startArg + '$__System._nodeRequire'; + }); return Promise.resolve({ source: output,