Skip to content

nameLazyFiles - ugly/unexpected names #9838

@janousek

Description

@janousek

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions