Skip to content

Impossible to create Angular library nested in multiple directories #23988

Closed as not planned
@DariuszOstolski

Description

@DariuszOstolski

Command

generate

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

11

Description

After migration to Angular 14 its no longer possible to create a library with nested directory structure. I'm working on a project where feature is usually split into multiple directories, for example:

projects/libs/feature-name/

  • app
  • shared
  • model
  • store

After migration when I try to create a library with a such scheme it is no longer possible, e.g.:

$ npx ng generate library projects/libs/feature/model                                                                                                                                                                                           ‹ruby-2.6.6›
Schematic input does not validate against the Schema: {"name":"projects/libs/feature/model"}
Errors:

  Data path "/name" must match pattern "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$".

I know that there is a workaround that when we make a path alias to projects/libs/feature-name it will work, e.g.:

$ npx ng generate library @feature-alias/model                                                                                                                                                                                           

In this project its very inconvenient since we have 100 different features and we would need to alias almost each one of it.

Minimal Reproduction

# create empty workspace
 ng new my-workspace --create-application false
# in that workspace create a library with nested directories
cd my-workspace/my-project
npx ng generate library projects/libs/feature/model

Exception or Error

Schematic input does not validate against the Schema: {"name":"projects/libs/feature/model"}
Errors:

  Data path "/name" must match pattern "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$".

Your Environment

$ ng version                                                                                                                                                                                                                                    ‹ruby-2.6.6›

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 14.2.4
Node: 16.17.0
Package Manager: npm 8.15.0 
OS: linux x64

Angular: 14.2.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.4
@angular-devkit/build-angular   14.2.4
@angular-devkit/core            14.2.4
@angular-devkit/schematics      14.2.4
@angular/cdk                    14.2.3
@angular/flex-layout            14.0.0-beta.40
@angular/material               14.2.3
@schematics/angular             14.2.4
ng-packagr                      14.2.1
rxjs                            7.5.7
typescript                      4.8.4

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions