@@ -55,7 +55,7 @@ interface IExtendedChunk extends Webpack.compilation.Chunk {
5555}
5656
5757interface IAssetPathOptions {
58- chunk : { } ;
58+ chunk : Webpack . compilation . Chunk ;
5959 contentHashType : string ;
6060}
6161
@@ -194,10 +194,17 @@ export class LocalizationPlugin implements Webpack.Plugin {
194194 options . contentHashType === 'javascript' &&
195195 assetPath . match ( Constants . LOCALE_FILENAME_PLACEHOLDER_REGEX )
196196 ) {
197- return assetPath . replace (
198- Constants . LOCALE_FILENAME_PLACEHOLDER_REGEX ,
199- `" + ${ Constants . JSONP_PLACEHOLDER } + "`
197+ if ( options . chunk . id . match ( / ^ \" + / ) ) { // Does this look like an async chunk URL generator?
198+ return assetPath . replace (
199+ Constants . LOCALE_FILENAME_PLACEHOLDER_REGEX ,
200+ `" + ${ Constants . JSONP_PLACEHOLDER } + "`
201+ ) ;
202+ } else {
203+ return assetPath . replace (
204+ Constants . LOCALE_FILENAME_PLACEHOLDER_REGEX ,
205+ Constants . LOCALE_NAME_PLACEHOLDER
200206 ) ;
207+ }
201208 } else {
202209 return assetPath ;
203210 }
@@ -307,7 +314,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
307314 }
308315
309316 if ( EntityMarker . getMark ( chunk ) ) {
310-
311317 processChunkJsFile ( ( chunkFilename ) => {
312318 if ( chunkFilename . indexOf ( Constants . LOCALE_NAME_PLACEHOLDER ) === - 1 ) {
313319 throw new Error ( `Asset ${ chunkFilename } is expected to be localized, but is missing a locale placeholder` ) ;
@@ -356,10 +362,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
356362 } ) ;
357363 } else {
358364 processChunkJsFile ( ( chunkFilename ) => {
359- if ( chunkFilename . indexOf ( Constants . LOCALE_NAME_PLACEHOLDER ) !== - 1 ) {
360- throw new Error ( `Asset ${ chunkFilename } is not expected to be localized, but has a locale placeholder` ) ;
361- }
362-
363365 const asset : IAsset = compilation . assets [ chunkFilename ] ;
364366
365367 const resultingAsset : IProcessAssetResult = AssetProcessor . processNonLocalizedAsset ( {
0 commit comments