1
+ import { join } from 'path' ;
1
2
import { getParsedDeepLinkConfig } from '../util/helpers' ;
2
3
import { BuildContext , DeepLinkConfigEntry } from '../util/interfaces' ;
3
4
import { Logger } from '../logger/logger' ;
4
5
import { getInstance } from '../util/hybrid-file-system-factory' ;
5
- import { createResolveDependenciesFromContextMap } from './util' ;
6
6
import { WatchMemorySystem } from './watch-memory-system' ;
7
7
8
+ import * as ContextElementDependency from 'webpack/lib/dependencies/ContextElementDependency' ;
9
+
8
10
export class IonicEnvironmentPlugin {
9
11
constructor ( private context : BuildContext ) {
10
12
}
@@ -18,10 +20,26 @@ export class IonicEnvironmentPlugin {
18
20
if ( ! result ) {
19
21
return callback ( ) ;
20
22
}
23
+
24
+ const ngModuleLoaderDirectory = join ( 'ionic-angular' , 'util' ) ;
25
+ if ( ! result . resource . endsWith ( ngModuleLoaderDirectory ) ) {
26
+ return callback ( null , result ) ;
27
+ }
28
+
21
29
result . resource = this . context . srcDir ;
22
30
result . recursive = true ;
23
31
result . dependencies . forEach ( ( dependency : any ) => dependency . critical = false ) ;
24
- result . resolveDependencies = createResolveDependenciesFromContextMap ( ( _ : any , cb : any ) => cb ( null , webpackDeepLinkModuleDictionary ) ) ;
32
+ result . resolveDependencies = ( p1 : any , p2 : any , p3 : any , p4 : RegExp , cb : any ) => {
33
+ const dependencies = Object . keys ( webpackDeepLinkModuleDictionary )
34
+ . map ( ( key ) => {
35
+ const value = webpackDeepLinkModuleDictionary [ key ] ;
36
+ if ( value ) {
37
+ return new ContextElementDependency ( value , key ) ;
38
+ }
39
+ return null ;
40
+ } ) . filter ( dependency => ! ! dependency ) ;
41
+ cb ( null , dependencies ) ;
42
+ } ;
25
43
return callback ( null , result ) ;
26
44
} ) ;
27
45
} ) ;
0 commit comments