Skip to content

Commit f46dac8

Browse files
committed
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 = ;;`
1 parent 288c7b0 commit f46dac8

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎lib/RequireJsStuffPlugin.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ module.exports = class RequireJsStuffPlugin {
1919
if(typeof parserOptions.requireJs !== "undefined" && !parserOptions.requireJs)
2020
return;
2121

22-
parser.plugin("call require.config", ParserHelpers.toConstantDependency(";"));
23-
parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency(";"));
22+
parser.plugin("call require.config", ParserHelpers.toConstantDependency("undefined"));
23+
parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency("undefined"));
2424

2525
parser.plugin("expression require.version", ParserHelpers.toConstantDependency(JSON.stringify("0.0.0")));
2626
parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency(JSON.stringify("__webpack_require__.oe")));

‎test/RequireJsStuffPlugin.test.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe("RequireJsStuffPlugin", function() {
136136
var addDependencySpy = parserEventContext.state.current.addDependency;
137137
var addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
138138
addDependencySpy.callCount.should.be.exactly(1);
139-
addedDependency.should.be.exactly('{"module":null,"expression":";","range":10,"loc":5}');
139+
addedDependency.should.be.exactly('{"module":null,"expression":"undefined","range":10,"loc":5}');
140140
});
141141
});
142142
});
@@ -159,7 +159,7 @@ describe("RequireJsStuffPlugin", function() {
159159
const addDependencySpy = parserEventContext.state.current.addDependency;
160160
const addedDependency = JSON.stringify(addDependencySpy.getCall(0).args[0]);
161161
addDependencySpy.callCount.should.be.exactly(1);
162-
addedDependency.should.be.exactly('{"module":null,"expression":";","range":10,"loc":5}');
162+
addedDependency.should.be.exactly('{"module":null,"expression":"undefined","range":10,"loc":5}');
163163
});
164164
});
165165
});

0 commit comments

Comments
 (0)