Versions
@ngtools/webpack: 6.0.0-beta.4
Repro steps
- Create app with lazy loaded routes where modules are in some subdirectory (not in the root directory).
- Compile app using webpack AngularCompilerPlugin with nameLazyFiles set to true + output.chunkFilename set to '[name].chunk.js',
Observed behavior
Relative filesystem path to the compiled module is:
.\SubjectCommon\js\controllers\credit\credit.module.ts
and the name of the coresponding chunk is:
SubjectCommon-js-controllers-credit-credit-module-ngfactory.chunk.js
Desired behavior
Chunk name should be:
credit.module.chunk.js
Mention any other details that might be useful (optional)
I belive that option "nameLazyFiles" should replace existing plugin NamedLazyChunksWebpackPlugin (from previous version of CLI). But it works differently. NamedLazyChunksWebpackPlugin generated correct name "credit.module.chunk.js".
The problem is on this line:
|
const name = importPath.replace(/(\.ngfactory)?\.(js|ts)$/, ''); |
"importPath" contains path to the factory file without any extension (regex is not correct because it expect extension). And just the name of the factory file should be used. Not whole path.
Versions
Repro steps
Observed behavior
Desired behavior
Mention any other details that might be useful (optional)
I belive that option "nameLazyFiles" should replace existing plugin NamedLazyChunksWebpackPlugin (from previous version of CLI). But it works differently. NamedLazyChunksWebpackPlugin generated correct name "credit.module.chunk.js".
The problem is on this line:
angular-cli/packages/@ngtools/webpack/src/angular_compiler_plugin.ts
Line 598 in 71f3822
"importPath" contains path to the factory file without any extension (regex is not correct because it expect extension). And just the name of the factory file should be used. Not whole path.