-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
NGCC failure with libraries of similar names #40352
Comments
Hi, I had a look at this and what is happening is that during the first run. NGCC will run on all What I noticed is that when running the NGCC during module resolution (2nd run) it breaks the library as this is not processed correctly. (Notice: This issue seems to be a duplicate of https://github.com/angular/angular-cli/issues/19484 |
Duplicate of #40357 |
I have found the source of the bug - working on a fix. |
Previously, if an entry-point started with the string of another package that is included in `paths` mappings, then the base path was incorrectly computed resulting in the wrong package path for the entry point. Now we not only check whether the target path "starts with" the base path but then also whether the target path is actually contained in the base path from a file-system directory point of view. Fixes angular#40352 Fixes angular#40357
Previously, if there were path-mapped entry-points, where one contaied the string of another - for example `worker-client` and `worker` - then the base paths were incorrectly computed resulting in the wrong package path for the longer entry-point. This was because, when searching for a matching base path, the strings were tested using `startsWith()`, whereas we should only match if the path was contained in a directory from a file-system point of view. Now we not only check whether the target path "starts with" the base path but then also whether the target path is actually contained in the base path using `fs.relative()`. Fixes angular#40352 Fixes angular#40357
…40376) Previously, if there were path-mapped entry-points, where one contaied the string of another - for example `worker-client` and `worker` - then the base paths were incorrectly computed resulting in the wrong package path for the longer entry-point. This was because, when searching for a matching base path, the strings were tested using `startsWith()`, whereas we should only match if the path was contained in a directory from a file-system point of view. Now we not only check whether the target path "starts with" the base path but then also whether the target path is actually contained in the base path using `fs.relative()`. Fixes #40352 Fixes #40357 PR Close #40376
…40376) Previously, if there were path-mapped entry-points, where one contaied the string of another - for example `worker-client` and `worker` - then the base paths were incorrectly computed resulting in the wrong package path for the longer entry-point. This was because, when searching for a matching base path, the strings were tested using `startsWith()`, whereas we should only match if the path was contained in a directory from a file-system point of view. Now we not only check whether the target path "starts with" the base path but then also whether the target path is actually contained in the base path using `fs.relative()`. Fixes #40352 Fixes #40357 PR Close #40376
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
@angular/compiler-cli - ngcc
Is this a regression?
Pretty sure it worked in older versions.
Description
If two libraries have the same name, but the second one has the additional suffix, the ngcc will fail.
Example
demo-lib
demo-lib-shell
demo-lib
importsdemo-lib-shell
module anddemo-lib
is imported by the application.Additional observation
To my surprise, the failure only happens if
demo-lib-shell
library is configured afterdemo-lib
intsconfig.json
paths, as in:If this configuration is reversed,
ngcc
will not fail.🔬 Minimal Reproduction
Clone: https://github.com/klemenoslaj/ngcc-failure--library-name
Install dependencies:
yarn
Reproduce the issue:
yarn reproduce
ORyarn reproduce:docker
NOTE: There is a chance that on the first try right after dependency installation this will succeed, but will fail when
yarn reproduce
is executed again. This probably has something to do with the fact that the rest of dependencies fromnode_modules
are processed as well first time, but I could be wrong.NOTE 2: This seems to fail consistantly even on the first try in Docker. To that end I have added a docker file and updated the reproduction above accordingly.
🔥 Exception or Error
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: