mirror of https://github.com/webpack/webpack.git
fix issue where `requirejs.config()` would be evaluated to `;` instead of `undefined`
this may lead to potential Syntaxerrors as `const x = requirejs.config();` would be transformed to `const x = ;;`
This commit is contained in:
parent
288c7b07f7
commit
f46dac81c0
|
|
@ -19,8 +19,8 @@ module.exports = class RequireJsStuffPlugin {
|
||||||
if(typeof parserOptions.requireJs !== "undefined" && !parserOptions.requireJs)
|
if(typeof parserOptions.requireJs !== "undefined" && !parserOptions.requireJs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
parser.plugin("call require.config", ParserHelpers.toConstantDependency(";"));
|
parser.plugin("call require.config", ParserHelpers.toConstantDependency("undefined"));
|
||||||
parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency(";"));
|
parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency("undefined"));
|
||||||
|
|
||||||
parser.plugin("expression require.version", ParserHelpers.toConstantDependency(JSON.stringify("0.0.0")));
|
parser.plugin("expression require.version", ParserHelpers.toConstantDependency(JSON.stringify("0.0.0")));
|
||||||
parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency(JSON.stringify("__webpack_require__.oe")));
|
parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency(JSON.stringify("__webpack_require__.oe")));
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ describe("RequireJsStuffPlugin", function() {
|
||||||
var addDependencySpy = parserEventContext.state.current.addDependency;
|
var addDependencySpy = parserEventContext.state.current.addDependency;
|
||||||
var addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
|
var addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
|
||||||
addDependencySpy.callCount.should.be.exactly(1);
|
addDependencySpy.callCount.should.be.exactly(1);
|
||||||
addedDependency.should.be.exactly('{"module":null,"expression":";","range":10,"loc":5}');
|
addedDependency.should.be.exactly('{"module":null,"expression":"undefined","range":10,"loc":5}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -159,7 +159,7 @@ describe("RequireJsStuffPlugin", function() {
|
||||||
const addDependencySpy = parserEventContext.state.current.addDependency;
|
const addDependencySpy = parserEventContext.state.current.addDependency;
|
||||||
const addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
|
const addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
|
||||||
addDependencySpy.callCount.should.be.exactly(1);
|
addDependencySpy.callCount.should.be.exactly(1);
|
||||||
addedDependency.should.be.exactly('{"module":null,"expression":";","range":10,"loc":5}');
|
addedDependency.should.be.exactly('{"module":null,"expression":"undefined","range":10,"loc":5}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue