Skip to content

Commit 0251e62

Browse files
author
Chuck Dumont
committed
Support DLLPlugin
1 parent 69e3433 commit 0251e62

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

lib/DojoAMDModuleFactoryPlugin.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const {newNormalModule} = require("./compat");
1919
const DojoAMDRequireItemDependency = require("./DojoAMDRequireItemDependency");
2020
const {reg, tap, callSync, callSyncBail} = require("./pluginCompat").for("dojo-webpack-plugin");
2121
const SingleEntryDependency = require("webpack/lib/dependencies/SingleEntryDependency");
22+
const Module = require("webpack/lib/Module");
2223

2324
module.exports = class DojoAMDModuleFactoryPlugin {
2425
constructor(options) {
@@ -210,13 +211,20 @@ module.exports = class DojoAMDModuleFactoryPlugin {
210211
}
211212

212213
module(module) {
214+
if (module.originalRequest instanceof Module) {
215+
// Copy absMids from original request to the new request
216+
callSync(this.factory, "filter absMids", module.originalRequest, absMid => {
217+
callSync(this.factory, "add absMid", module, absMid);
218+
return true;
219+
});
220+
}
213221
// If the module already exists in the compilation, then copy the absMid data from
214222
// this module to the existing module since this module will be discarded
215223
const existing = this.compilation.findModule(module.request);
216-
if (existing && module.absMid) {
217-
callSync(this.factory, "add absMid", existing, module.absMid);
218-
(module.absMidAliases||[]).forEach(absMid => {
224+
if (existing) {
225+
callSync(this.factory, "filter absMids", module, absMid => {
219226
callSync(this.factory, "add absMid", existing, absMid);
227+
return true;
220228
});
221229
}
222230
// Add functions to the module object for adding/filtering absMids (for use by loaders)

test/DojoAMDModuleFactoryPlugin.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
const DojoAMDModuleFactoryPlugin = require("../lib/DojoAMDModuleFactoryPlugin");
1010
const {Tapable, reg, callSync, callSyncWaterfall} = require("../lib/pluginCompat");
11+
const Module = require("webpack/lib/Module");
1112
const plugin = new DojoAMDModuleFactoryPlugin({});
1213

1314
class Factory extends Tapable {
@@ -203,6 +204,19 @@ describe("DojoAMDModuleFactoryPlugin tests", function() {
203204
existing.absMid.should.eql('a');
204205
existing.absMidAliases.length.should.eql(0);
205206
});
207+
208+
it("Should copy absMids from original request of delgated modules", function() {
209+
const originalModule = new Module("test");
210+
const delegated = {originalRequest: originalModule};
211+
callSync(factory, "add absMid", originalModule, "a");
212+
compilation.findModule = function() { return null; };
213+
debugger; // eslint-disable-line
214+
const result = callSyncWaterfall(factory, "module", delegated);
215+
result.should.be.eql(delegated);
216+
result.absMid.should.eql('a');
217+
result.absMidAliases.length.should.eql(0);
218+
originalModule.absMid.should.eql('a');
219+
});
206220
});
207221

208222
describe("toAbsMid tests", function() {

0 commit comments

Comments
 (0)