@@ -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,18 @@ 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+ // Does this look like an async chunk URL generator?
198+ if ( typeof options . chunk . id === 'string' && options . chunk . id . match ( / ^ \" \+ / ) ) {
199+ return assetPath . replace (
200+ Constants . LOCALE_FILENAME_PLACEHOLDER_REGEX ,
201+ `" + ${ Constants . JSONP_PLACEHOLDER } + "`
202+ ) ;
203+ } else {
204+ return assetPath . replace (
205+ Constants . LOCALE_FILENAME_PLACEHOLDER_REGEX ,
206+ Constants . LOCALE_NAME_PLACEHOLDER
200207 ) ;
208+ }
201209 } else {
202210 return assetPath ;
203211 }
@@ -307,7 +315,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
307315 }
308316
309317 if ( EntityMarker . getMark ( chunk ) ) {
310-
311318 processChunkJsFile ( ( chunkFilename ) => {
312319 if ( chunkFilename . indexOf ( Constants . LOCALE_NAME_PLACEHOLDER ) === - 1 ) {
313320 throw new Error ( `Asset ${ chunkFilename } is expected to be localized, but is missing a locale placeholder` ) ;
@@ -356,10 +363,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
356363 } ) ;
357364 } else {
358365 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-
363366 const asset : IAsset = compilation . assets [ chunkFilename ] ;
364367
365368 const resultingAsset : IProcessAssetResult = AssetProcessor . processNonLocalizedAsset ( {
0 commit comments