Skip to content

Commit e776bcb

Browse files
author
Chuck Dumont
authored
Merge pull request #26 from chuckdumont/work2
Fix webpack 2 compatibility regressions
2 parents 0f9ac60 + 8bf44a5 commit e776bcb

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lib/DojoAMDMainTemplatePlugin.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ module.exports = class DojoAMDMainTemplatePlugin {
123123
}
124124

125125
function hasAMD(chunk) {
126-
return chunk.getModules().some((module) => {
126+
var modules = chunk.getModules ? chunk.getModules() : chunk.modules;
127+
return modules.some((module) => {
127128
return module.isAMD;
128129
});
129130
}

lib/DojoLoaderEnsurePlugin.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2012, 2016 All Rights Reserved.
2+
* (C) Copyright IBM Corp. 2017 All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,11 +16,20 @@
1616
const util = require('util');
1717

1818
function hasAMD(chunk) {
19-
return chunk.getModules().some((module) => {
19+
var modules = chunk.getModules ? chunk.getModules() : chunk.modules;
20+
return modules.some((module) => {
2021
return module.isAMD;
2122
});
2223
}
2324

25+
function containsModule(chunk, module) {
26+
if (chunk.containsModule) {
27+
return chunk.containsModule(module);
28+
} else {
29+
return chunk.modules.indexOf(module) !== -1;
30+
}
31+
}
32+
2433
module.exports = class DojoLoaderEnsurePlugin {
2534
constructor(options) {
2635
this.options = options;
@@ -29,7 +38,6 @@ module.exports = class DojoLoaderEnsurePlugin {
2938
// Ensure that the Dojo loader, and optionally the loader config, are included
3039
// in each entry chunk that has any AMD modules.
3140
compilation.plugin("after-optimize-chunks", (chunks) => {
32-
debugger;
3341
if (!compilation.dojoLoaderDependenciesAdded) {
3442
return; // Nothing to do for this compilation
3543
}
@@ -47,11 +55,11 @@ module.exports = class DojoLoaderEnsurePlugin {
4755
}
4856
chunks.forEach((chunk) => {
4957
if (chunk.hasRuntime() && hasAMD(chunk)) {
50-
if (!chunk.containsModule(loaderModule)) {
58+
if (!containsModule(chunk, loaderModule)) {
5159
chunk.addModule(loaderModule);
5260
loaderModule.addChunk(chunk);
5361
}
54-
if (configModule && !chunk.containsModule(configModule)) {
62+
if (configModule && !containsModule(chunk, configModule)) {
5563
chunk.addModule(configModule);
5664
configModule.addChunk(chunk);
5765
}

0 commit comments

Comments
 (0)