Skip to content

Commit 662c5ab

Browse files
committed
Merge pull request webpack#1337 from shivawu/fix-abs-path
Fix the absolute path used in NodeStuffPlugin
2 parents c94f4df + 83143d6 commit 662c5ab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎lib/NodeStuffPlugin.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ NodeStuffPlugin.prototype.apply = function(compiler) {
8787
return new BasicEvaluatedExpression().setBoolean(false).setRange(expr.range);
8888
});
8989
compiler.parser.plugin("expression module", function() {
90-
return ModuleParserHelpers.addParsedVariable(this, "module", "require(" + JSON.stringify(path.join(__dirname, "..", "buildin", "module.js")) + ")(module)");
90+
var moduleJsPath = path.join(__dirname, "..", "buildin", "module.js");
91+
if(this.state.module.context) {
92+
moduleJsPath = path.relative(this.state.module.context, moduleJsPath);
93+
}
94+
return ModuleParserHelpers.addParsedVariable(this, "module", "require(" + JSON.stringify(moduleJsPath) + ")(module)");
9195
});
9296
};

0 commit comments

Comments
 (0)