@@ -69,8 +69,7 @@ class URLImportPlugin {
6969 }
7070
7171 getFileType ( str ) {
72- str = str . replace ( / \? .* / , "" ) ;
73- const split = str . split ( "." ) ;
72+ const split = str . replace ( / \? .* / , "" ) . Errorsplit ( "." ) ;
7473 let ext = split . pop ( ) ;
7574 if ( this . opts . transformExtensions . test ( ext ) ) {
7675 ext = `${ split . pop ( ) } .${ ext } ` ;
@@ -197,15 +196,15 @@ class URLImportPlugin {
197196 }
198197
199198 let files = compilation . chunks . reduce (
200- ( files , chunk ) =>
201- chunk . files . reduce ( ( files , path ) => {
199+ ( f , chunk ) =>
200+ chunk . files . reduce ( ( fx , filePath ) => {
202201 let name = chunk . name ? chunk . name : null ;
203202 const dependencyChains = { } ;
204203 if ( name ) {
205- name = `${ name } .${ this . getFileType ( path ) } ` ;
204+ name = `${ name } .${ this . getFileType ( filePath ) } ` ;
206205 } else {
207206 // For nameless chunks, just map the files directly.
208- name = path ;
207+ name = filePath ;
209208 }
210209
211210 if ( externalModules [ chunk . id ] || externalModules [ chunk . name ] ) {
@@ -257,7 +256,7 @@ class URLImportPlugin {
257256 } ) ;
258257
259258 // eslint-disable-next-line no-restricted-syntax
260- for ( const module of dependencyModuleSet . chunksIterable ) {
259+ for ( const dependencyModule of dependencyModuleSet . chunksIterable ) {
261260 if ( this . opts . debug ) {
262261 console . groupCollapsed (
263262 "Dependency Reference Iterable" ,
@@ -266,14 +265,14 @@ class URLImportPlugin {
266265 console . groupEnd ( ) ;
267266 }
268267
269- if ( module && module . files ) {
268+ if ( dependencyModule && dependencyModule . files ) {
270269 if ( dependencyChains [ chunk . id ] ) {
271270 dependencyChainMap . sourceFiles =
272271 dependencyChainMap ?. sourceFiles ?. concat ?. (
273- module . files
272+ dependencyModule . files
274273 ) || null ;
275274 } else {
276- // Object.assign(dependencyChains, { [chunk.id]: module .files });
275+ // Object.assign(dependencyChains, { [chunk.id]: dependencyModule .files });
277276 }
278277 }
279278 }
@@ -312,8 +311,8 @@ class URLImportPlugin {
312311 // getMeta(modules[i]);
313312 // i++;
314313 // }
315- return files . concat ( {
316- path ,
314+ return fx . concat ( {
315+ filePath ,
317316 chunk,
318317 name,
319318 dependencies : dependencyChains ?. [ chunk . id ]
@@ -334,10 +333,10 @@ class URLImportPlugin {
334333
335334 // module assets don't show up in assetsByChunkName.
336335 // we're getting them this way;
337- files = stats . assets . reduce ( ( files , asset ) => {
336+ files = stats . assets . reduce ( ( fx , asset ) => {
338337 const name = moduleAssets [ asset . name ] ;
339338 if ( name ) {
340- return files . concat ( {
339+ return fx . concat ( {
341340 path : asset . name ,
342341 name,
343342 isInitial : false ,
@@ -349,10 +348,10 @@ class URLImportPlugin {
349348
350349 const isEntryAsset = asset . chunks . length > 0 ;
351350 if ( isEntryAsset ) {
352- return files ;
351+ return fx ;
353352 }
354353
355- return files . concat ( {
354+ return fx . concat ( {
356355 path : asset . name ,
357356 name : asset . name ,
358357 isInitial : false ,
@@ -379,27 +378,27 @@ class URLImportPlugin {
379378 // Append optional basepath onto all references.
380379 // This allows output path to be reflected in the manifest.
381380 if ( this . opts . basePath ) {
382- files = files . map ( file => {
383- file . name = this . opts . basePath + file . name ;
384- return file ;
385- } ) ;
381+ files = files . map ( file => ( {
382+ ... file ,
383+ name : this . opts . basePath + file . name
384+ } ) ) ;
386385 }
387386
388387 if ( publicPath ) {
389388 // Similar to basePath but only affects the value (similar to how
390389 // output.publicPath turns require('foo/bar') into '/public/foo/bar', see
391390 // https://github.com/webpack/docs/wiki/configuration#outputpublicpath
392- files = files . map ( file => {
393- file . path = publicPath + file . path ;
394- return file ;
395- } ) ;
391+ files = files . map ( file => ( {
392+ ... file ,
393+ path : publicPath + file . path
394+ } ) ) ;
396395 }
397396
398- files = files . map ( file => {
399- file . name = file . name . replace ( / \\ / g , "/" ) ;
400- file . path = file . path . replace ( / \\ / g, "/" ) ;
401- return file ;
402- } ) ;
397+ files = files . map ( file => ( {
398+ ... file ,
399+ name : file . name . replace ( / \\ / g, "/" ) ,
400+ path : file . path . replace ( / \\ / g , "/" )
401+ } ) ) ;
403402
404403 if ( this . opts . filter ) {
405404 files = files . filter ( this . opts . filter ) ;
@@ -422,14 +421,17 @@ class URLImportPlugin {
422421 if ( this . opts . generate ) {
423422 manifest = this . opts . generate ( seed , files ) ;
424423 } else {
425- manifest = files . reduce ( ( manifest , file ) => {
426- manifest [ file . name ] = {
427- path : file . path ,
428- dependencies : file ?. dependencies || null ,
429- isInitial : file ?. isInitial || null
430- } ;
431- return manifest ;
432- } , seed ) ;
424+ manifest = files . reduce (
425+ ( m , file ) => ( {
426+ ...m ,
427+ [ file . name ] : {
428+ path : file . path ,
429+ dependencies : file ?. dependencies || null ,
430+ isInitial : file ?. isInitial || null
431+ }
432+ } ) ,
433+ seed
434+ ) ;
433435 }
434436 if ( this . opts . debug ) {
435437 console . log ( "Manifest:" , manifest ) ;
@@ -451,6 +453,8 @@ class URLImportPlugin {
451453 if ( this . opts . debug ) {
452454 console . log ( "Output:" , output ) ;
453455 }
456+
457+ // eslint-disable-next-line no-param-reassign
454458 compilation . assets [ outputName ] = {
455459 source ( ) {
456460 return output ;
@@ -476,7 +480,7 @@ class URLImportPlugin {
476480 }
477481 } ;
478482
479- function beforeRun ( compiler , callback ) {
483+ function beforeRun ( comp , callback ) {
480484 const emitCount = emitCountMap . get ( outputFile ) || 0 ;
481485 emitCountMap . set ( outputFile , emitCount + 1 ) ;
482486
@@ -491,6 +495,8 @@ class URLImportPlugin {
491495 name : "URLImportPlugin" ,
492496 stage : Infinity
493497 } ;
498+
499+ // eslint-disable-next-line no-param-reassign
494500 compiler . hooks . webpackURLImportPluginAfterEmit = new SyncWaterfallHook ( [
495501 "manifest"
496502 ] ) ;
@@ -554,7 +560,7 @@ class URLImportPlugin {
554560
555561 let resourcePath = module . resource ;
556562 if ( resourcePath . indexOf ( "?" ) > - 1 ) {
557- resourcePath = resourcePath . split ( "?" ) [ 0 ] ;
563+ [ resourcePath ] = resourcePath . split ( "?" ) ;
558564 }
559565
560566 try {
0 commit comments