1
1
/*
2
- * (C) Copyright IBM Corp. 2012, 2016 All Rights Reserved.
2
+ * (C) Copyright IBM Corp. 2017 All Rights Reserved.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
const util = require ( 'util' ) ;
17
17
18
18
function hasAMD ( chunk ) {
19
- return chunk . getModules ( ) . some ( ( module ) => {
19
+ var modules = chunk . getModules ? chunk . getModules ( ) : chunk . modules ;
20
+ return modules . some ( ( module ) => {
20
21
return module . isAMD ;
21
22
} ) ;
22
23
}
23
24
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
+
24
33
module . exports = class DojoLoaderEnsurePlugin {
25
34
constructor ( options ) {
26
35
this . options = options ;
@@ -29,7 +38,6 @@ module.exports = class DojoLoaderEnsurePlugin {
29
38
// Ensure that the Dojo loader, and optionally the loader config, are included
30
39
// in each entry chunk that has any AMD modules.
31
40
compilation . plugin ( "after-optimize-chunks" , ( chunks ) => {
32
- debugger ;
33
41
if ( ! compilation . dojoLoaderDependenciesAdded ) {
34
42
return ; // Nothing to do for this compilation
35
43
}
@@ -47,11 +55,11 @@ module.exports = class DojoLoaderEnsurePlugin {
47
55
}
48
56
chunks . forEach ( ( chunk ) => {
49
57
if ( chunk . hasRuntime ( ) && hasAMD ( chunk ) ) {
50
- if ( ! chunk . containsModule ( loaderModule ) ) {
58
+ if ( ! containsModule ( chunk , loaderModule ) ) {
51
59
chunk . addModule ( loaderModule ) ;
52
60
loaderModule . addChunk ( chunk ) ;
53
61
}
54
- if ( configModule && ! chunk . containsModule ( configModule ) ) {
62
+ if ( configModule && ! containsModule ( chunk , configModule ) ) {
55
63
chunk . addModule ( configModule ) ;
56
64
configModule . addChunk ( chunk ) ;
57
65
}
0 commit comments