Current Behavior
When generating a library with the "@nx/angular:library" generator and using a directory together with simpleName=false the Library Name remains simple, although the documentation suggests the opposite: https://nx.dev/nx-api/angular/generators/library#simplename
nx g @nx/angular:library --directory=libs/path --name=test --standalone=false --simpleName=false --dry-run
Result
CREATE libs/path/project.json
CREATE libs/path/README.md
CREATE libs/path/tsconfig.json
CREATE libs/path/tsconfig.lib.json
CREATE libs/path/src/index.ts
CREATE libs/path/src/lib/test.module.ts
CREATE libs/path/jest.config.ts
CREATE libs/path/src/test-setup.ts
CREATE libs/path/tsconfig.spec.json
CREATE libs/path/.eslintrc.json
UPDATE tsconfig.base.json
Expected Behavior
I would expect the module to have the name "path-test.module.ts".
nx g @nx/angular:library --directory=libs/path --name=test --standalone=false --simpleName=false --dry-run
Result
CREATE libs/path/project.json
CREATE libs/path/README.md
CREATE libs/path/tsconfig.json
CREATE libs/path/tsconfig.lib.json
CREATE libs/path/src/index.ts
CREATE libs/path/src/lib/path-test.module.ts
CREATE libs/path/jest.config.ts
CREATE libs/path/src/test-setup.ts
CREATE libs/path/tsconfig.spec.json
CREATE libs/path/.eslintrc.json
UPDATE tsconfig.base.json
GitHub Repo
No response
Steps to Reproduce
- Execute
nx g @nx/angular:library --directory=libs/path --name=test --standalone=false --simpleName=false --dry-run
Nx Report
Node : 22.12.0
OS : darwin-arm64
Native Target : aarch64-macos
yarn : 1.22.19
nx : 20.3.0
@nx/js : 20.3.0
@nx/jest : 20.3.0
@nx/eslint : 20.3.0
@nx/workspace : 20.3.0
@nx/angular : 20.3.0
@nx/cypress : 20.3.0
@nx/devkit : 20.3.0
@nx/eslint-plugin : 20.3.0
@nx/module-federation : 20.3.0
@nx/plugin : 20.3.0
@nx/storybook : 20.3.0
@nx/web : 20.3.0
@nx/webpack : 20.3.0
typescript : 5.6.3
---------------------------------------
Community plugins:
@compodoc/compodoc : 1.1.18
@ngrx/component-store : 19.0.0
@ngrx/effects : 19.0.0
@ngrx/entity : 19.0.0
@ngrx/operators : 19.0.0
@ngrx/router-store : 19.0.0
@ngrx/schematics : 19.0.0
@ngrx/store : 19.0.0
@ngrx/store-devtools : 19.0.0
@storybook/angular : 8.4.7
---------------------------------------
Local workspace plugins:
@nw/workspace-plugin
Failure Logs
Package Manager Version
yarn version 1.22.19
Operating System
Additional Information
I debugged the issue and the name is passed to the generator as libFileName:
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/files/ng-module/src/lib/libFileName.module.ts__tpl__
This is passed from createFiles-Method called here:
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/library.ts#L78
The methods utilizes options.libraryOptions.fileName
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/lib/create-files.ts#L35
This is created in the normalizeOptions Method called here
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/lib/create-files.ts#L35
This gets the fileName using a method called determineProjectNameAndRootOptions to determine the the fileName based on the option passed to the schematic:
const fileName = options.simpleName
? projectNames.projectSimpleName
: projectNames.projectFileName;
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/lib/normalize-options.ts#L45
However, this methods only returns a differing projectFileName when the name starts with an @.
if (name.startsWith('@')) {
const [_scope, ...rest] = name.split('/');
projectFileName = rest.join('-');
projectSimpleName = rest.pop();
} else {
projectSimpleName = name;
projectFileName = name;
}
https://github.com/nrwl/nx/blob/master/packages/devkit/src/generators/project-name-and-root-utils.ts#L62
This seems to be the root cause, but I don't understand if this is working as designed and I need to change my parameters, but trying different variations (like adding an @ to the name or directory) of the generator did not vary anything.
Current Behavior
When generating a library with the "@nx/angular:library" generator and using a directory together with simpleName=false the Library Name remains simple, although the documentation suggests the opposite: https://nx.dev/nx-api/angular/generators/library#simplename
nx g @nx/angular:library --directory=libs/path --name=test --standalone=false --simpleName=false --dry-runResult
Expected Behavior
I would expect the module to have the name "path-test.module.ts".
nx g @nx/angular:library --directory=libs/path --name=test --standalone=false --simpleName=false --dry-runResult
GitHub Repo
No response
Steps to Reproduce
nx g @nx/angular:library --directory=libs/path --name=test --standalone=false --simpleName=false --dry-runNx Report
Failure Logs
Package Manager Version
yarn version 1.22.19
Operating System
Additional Information
I debugged the issue and the name is passed to the generator as
libFileName:https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/files/ng-module/src/lib/libFileName.module.ts__tpl__
This is passed from createFiles-Method called here:
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/library.ts#L78
The methods utilizes
options.libraryOptions.fileNamehttps://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/lib/create-files.ts#L35
This is created in the normalizeOptions Method called here
https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/lib/create-files.ts#L35
This gets the fileName using a method called
determineProjectNameAndRootOptionsto determine the the fileName based on the option passed to the schematic:https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/lib/normalize-options.ts#L45
However, this methods only returns a differing projectFileName when the name starts with an
@.https://github.com/nrwl/nx/blob/master/packages/devkit/src/generators/project-name-and-root-utils.ts#L62
This seems to be the root cause, but I don't understand if this is working as designed and I need to change my parameters, but trying different variations (like adding an
@to the name or directory) of the generator did not vary anything.