Skip to content

Module resolution is broken when wildcard path exists #10376

Closed

Description

@jonrimmer

Versions

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.7.4
Node: 9.9.0
OS: darwin x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Repro steps

Add the following to tsconfig.json:

  1. Create a new CLI project:

ng new angular-cli-is-broken

  1. Add a wildcard path mapping to the tsconfig:
"paths": {
  "*": ["./src/app/*"]
}
  1. Build the project:
npm run build

Observed behavior

Resolution of modules does not work:

ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '/Users/jon/GitHub/angular-cli-is-broken/src/src/app/@angular/common' in '/Users/jon/GitHub/angular-cli-is-broken/src/app'

Etc.

Desired behavior

It should resolve modules correctly, as it did in 1.6.

Mention any other details that might be useful (optional)

This worked perfectly in 1.6. You can confirm this by regressing the CLI version in package.json to 1.6, and confirming that ng build now works.

Activity

  1. clydin commented on Apr 19, 2018

    @clydin
    Member

    TypeScript path resolution was working improperly previously and has since been fixed. The current behavior more correctly follows the behavior of TypeScript itself. For additional details regarding TypeScript's module resolution, please view the documentation here: http://www.typescriptlang.org/docs/handbook/module-resolution.html

  2. jonrimmer commented on Apr 19, 2018

    @jonrimmer
    Author

    @clydin What!? That is simply not true, and trivially so to prove:

    https://github.com/jonrimmer/ts-module-resolution

    The example contains a wildcard path mapping from "*" to "./src/*", but it does not stop the "left-pad" dependency resolving. Just because something matches a wildcard doesn't mean that TS won't apply standard node module resolution, e.g. searching through the node_modules of parent directories until it finds a matching module.

  3. jonrimmer commented on Apr 20, 2018

    @jonrimmer
    Author

    @clydin Are you going to reopen this, or should I file a new bug? Since the bug is in ngtools/webpack's paths plugin, should I file a bug in the devkit project?

  4. reopened this on Aug 10, 2018
  5. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  6. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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