Skip to content

Module resolution is broken when wildcard path exists #10376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jonrimmer opened this issue Apr 18, 2018 · 4 comments · Fixed by #11575
Closed

Module resolution is broken when wildcard path exists #10376

jonrimmer opened this issue Apr 18, 2018 · 4 comments · Fixed by #11575

Comments

@jonrimmer
Copy link

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.

@clydin
Copy link
Member

clydin commented Apr 19, 2018

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

@clydin clydin closed this as completed Apr 19, 2018
@jonrimmer
Copy link
Author

jonrimmer commented Apr 19, 2018

@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.

@jonrimmer
Copy link
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?

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants