-
Notifications
You must be signed in to change notification settings - Fork 26.2k
fix(compiler-cli): shorten resolved module name in fileNameToModuleName to npm package name for typings #23231
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
fix(compiler-cli): shorten resolved module name in fileNameToModuleName to npm package name for typings #23231
Conversation
You can preview 12764a9 at https://pr23231-12764a9.ngbuilds.io/. |
12764a9
to
826fe9e
Compare
integration/bazel/BUILD.bazel
Outdated
# e.g. node_modules/xpath/docs/function resolvers.md | ||
"node_modules/**/docs/**", | ||
], | ||
srcs = glob(["/".join([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep it the other way (will be needed for hermeticity) and add node_modules/rxjs/**
to the excludes with a comment explaining why we need to test for this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// if the npm package typings matches the importedFile | ||
try { | ||
const modulePath = importedFile.substring(0, importedFile.length - moduleName.length) + importedFilePackageName; | ||
const packageJson = require(modulePath + '/package.json'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably gets called a lot, I think it's probably worth memoizing this lookup for performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
You can preview 826fe9e at https://pr23231-826fe9e.ngbuilds.io/. |
826fe9e
to
4619f11
Compare
You can preview 4619f11 at https://pr23231-4619f11.ngbuilds.io/. |
4619f11
to
912825a
Compare
You can preview 912825a at https://pr23231-912825a.ngbuilds.io/. |
eef9568
to
baf0c91
Compare
You can preview eef9568 at https://pr23231-eef9568.ngbuilds.io/. |
You can preview baf0c91 at https://pr23231-baf0c91.ngbuilds.io/. |
if (packageTypings === originalImportedFile) { | ||
moduleName = importedFilePackageName; | ||
} | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a comment explaining why ignoring the error is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…me to npm package name for typings
baf0c91
to
1954ad1
Compare
You can preview 1954ad1 at https://pr23231-1954ad1.ngbuilds.io/. |
…me to npm package name for typings (angular#23231) PR Close angular#23231
…me to npm package name for typings (angular#23231) PR Close angular#23231
…me to npm package name for typings (angular#23231) PR Close angular#23231
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently fileNameToModuleName resolves typings files to module names as such:
.../node_modules/@angular/core/core.d.ts
=>@angular/core/core
,.../node_modules/rxjs/index.d.ts
=>rxjs/index
.Issue Number: N/A
What is the new behavior?
If the typings in the npm package matches the imported file then the module name is resolved to the npm package name as such:
.../node_modules/@angular/core/core.d.ts
=>@angular/core
,.../node_modules/rxjs/index.d.ts
=>rxjs
.Does this PR introduce a breaking change?
Other information