@@ -16,9 +16,11 @@ class JsonpMainTemplatePlugin {
16
16
return otherChunksInEntry || onDemandChunks ;
17
17
} ;
18
18
// TODO refactor this
19
- if ( ! mainTemplate . hooks . jsonpScript )
19
+ if ( ! mainTemplate . hooks . jsonpScript ) {
20
20
mainTemplate . hooks . jsonpScript = new SyncWaterfallHook ( [ "source" , "chunk" , "hash" ] ) ;
21
- mainTemplate . plugin ( "local-vars" , ( source , chunk ) => {
21
+ }
22
+
23
+ mainTemplate . hooks . localVar . tap ( "JsonpMainTemplatePlugin" , ( source , chunk ) => {
22
24
if ( needChunkLoadingCode ( chunk ) ) {
23
25
return Template . asString ( [
24
26
source ,
@@ -35,7 +37,7 @@ class JsonpMainTemplatePlugin {
35
37
}
36
38
return source ;
37
39
} ) ;
38
- mainTemplate . plugin ( "jsonp-script ", ( _ , chunk , hash ) => {
40
+ mainTemplate . hooks . jsonpScript . tap ( "JsonpMainTemplatePlugin ", ( _ , chunk , hash ) => {
39
41
const chunkFilename = mainTemplate . outputOptions . chunkFilename ;
40
42
const chunkMaps = chunk . getChunkMaps ( ) ;
41
43
const crossOriginLoading = mainTemplate . outputOptions . crossOriginLoading ;
@@ -97,7 +99,7 @@ class JsonpMainTemplatePlugin {
97
99
"};" ,
98
100
] ) ;
99
101
} ) ;
100
- mainTemplate . plugin ( "require-ensure ", ( source , chunk , hash ) => {
102
+ mainTemplate . hooks . requireEnsure . tap ( "JsonpMainTemplatePlugin ", ( source , chunk , hash ) => {
101
103
return Template . asString ( [
102
104
source ,
103
105
"" ,
@@ -132,7 +134,7 @@ class JsonpMainTemplatePlugin {
132
134
"}" ,
133
135
] ) ;
134
136
} ) ;
135
- mainTemplate . plugin ( "require-extensions ", ( source , chunk ) => {
137
+ mainTemplate . hooks . requireExtensions . tap ( "JsonpMainTemplatePlugin ", ( source , chunk ) => {
136
138
if ( chunk . getNumberOfChunks ( ) === 0 ) return source ;
137
139
138
140
return Template . asString ( [
@@ -142,7 +144,7 @@ class JsonpMainTemplatePlugin {
142
144
`${ mainTemplate . requireFn } .oe = function(err) { console.error(err); throw err; };`
143
145
] ) ;
144
146
} ) ;
145
- mainTemplate . plugin ( "bootstrap ", ( source , chunk , hash ) => {
147
+ mainTemplate . hooks . bootstrap . tap ( "JsonpMainTemplatePlugin ", ( source , chunk , hash ) => {
146
148
if ( needChunkLoadingCode ( chunk ) ) {
147
149
return Template . asString ( [
148
150
source ,
@@ -203,7 +205,7 @@ class JsonpMainTemplatePlugin {
203
205
}
204
206
return source ;
205
207
} ) ;
206
- mainTemplate . plugin ( "startup ", ( source , chunk , hash ) => {
208
+ mainTemplate . hooks . startup . tap ( "JsonpMainTemplatePlugin ", ( source , chunk , hash ) => {
207
209
if ( needChunkLoadingCode ( chunk ) ) {
208
210
var jsonpFunction = mainTemplate . outputOptions . jsonpFunction ;
209
211
return Template . asString ( [
@@ -218,7 +220,7 @@ class JsonpMainTemplatePlugin {
218
220
}
219
221
return source ;
220
222
} ) ;
221
- mainTemplate . plugin ( "hot-bootstrap ", ( source , chunk , hash ) => {
223
+ mainTemplate . hooks . hotBootstrap . tap ( "JsonpMainTemplatePlugin ", ( source , chunk , hash ) => {
222
224
const hotUpdateChunkFilename = mainTemplate . outputOptions . hotUpdateChunkFilename ;
223
225
const hotUpdateMainFilename = mainTemplate . outputOptions . hotUpdateMainFilename ;
224
226
const crossOriginLoading = mainTemplate . outputOptions . crossOriginLoading ;
@@ -248,7 +250,7 @@ function hotDisposeChunk(chunkId) {
248
250
var parentHotUpdateCallback = window[${ JSON . stringify ( hotUpdateFunction ) } ];
249
251
window[${ JSON . stringify ( hotUpdateFunction ) } ] = ${ runtimeSource } ` ;
250
252
} ) ;
251
- mainTemplate . plugin ( "hash ", hash => {
253
+ mainTemplate . hooks . hash . tap ( "JsonpMainTemplatePlugin ", hash => {
252
254
hash . update ( "jsonp" ) ;
253
255
hash . update ( "5" ) ;
254
256
hash . update ( `${ mainTemplate . outputOptions . filename } ` ) ;
0 commit comments