File tree 1 file changed +11
-22
lines changed
1 file changed +11
-22
lines changed Original file line number Diff line number Diff line change @@ -32,28 +32,17 @@ class JsonpMainTemplatePlugin {
32
32
const allPrefetchChunks = chunk . getChildIdsByOrdersMap ( true ) . prefetch ;
33
33
return allPrefetchChunks && Object . keys ( allPrefetchChunks ) . length ;
34
34
} ;
35
- // TODO refactor this
36
- if ( ! mainTemplate . hooks . jsonpScript ) {
37
- mainTemplate . hooks . jsonpScript = new SyncWaterfallHook ( [
38
- "source" ,
39
- "chunk" ,
40
- "hash"
41
- ] ) ;
42
- }
43
- if ( ! mainTemplate . hooks . linkPreload ) {
44
- mainTemplate . hooks . linkPreload = new SyncWaterfallHook ( [
45
- "source" ,
46
- "chunk" ,
47
- "hash"
48
- ] ) ;
49
- }
50
- if ( ! mainTemplate . hooks . linkPrefetch ) {
51
- mainTemplate . hooks . linkPrefetch = new SyncWaterfallHook ( [
52
- "source" ,
53
- "chunk" ,
54
- "hash"
55
- ] ) ;
56
- }
35
+
36
+ // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
37
+ [ "jsonpScript" , "linkPreload" , "linkPrefetch" ] . forEach ( hook => {
38
+ if ( ! mainTemplate . hooks [ hook ] ) {
39
+ mainTemplate . hooks [ hook ] = new SyncWaterfallHook ( [
40
+ "source" ,
41
+ "chunk" ,
42
+ "hash"
43
+ ] ) ;
44
+ }
45
+ } ) ;
57
46
58
47
const getScriptSrcPath = ( hash , chunk , chunkIdExpression ) => {
59
48
const chunkFilename = mainTemplate . outputOptions . chunkFilename ;
You can’t perform that action at this time.
0 commit comments