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(cdk/schematics): avoid runtime errors thrown by devkit tree when TypeScript tries non-existent path #22982
Merged
wagnermaciel
merged 1 commit into
angular:master
from
devversion:schematics-fix-is-directory
Jun 16, 2021
Merged
fix(cdk/schematics): avoid runtime errors thrown by devkit tree when TypeScript tries non-existent path #22982
wagnermaciel
merged 1 commit into
angular:master
from
devversion:schematics-fix-is-directory
Jun 16, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devversion
added
merge safe
target: patch
This PR is targeted for the next patch release
labels
Jun 15, 2021
google-cla
bot
added
the
cla: yes
PR author has agreed to Google's Contributor License Agreement
label
Jun 15, 2021
devversion
force-pushed
the
schematics-fix-is-directory
branch
from
June 15, 2021 14:24
ab9cef9
to
9c30d95
Compare
crisbeto
approved these changes
Jun 15, 2021
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.
LGTM
devversion
force-pushed
the
schematics-fix-is-directory
branch
from
June 15, 2021 18:21
9c30d95
to
0515044
Compare
TypeScript resolves modules using a rather complicated module resolution algorithm. The algorithm tries various paths to determine a possible entry-point for a module. e.g. it also respects a containing `package.json` file, or respects the closest `node_modules` parent directory. In some situations, TypeScript could end up trying a path where a parent directory segment resolves to an existent file. e.g. consider the following directory structure: ``` node_modules/my-pkg/package.json node_modules/my-pkg/styles.css ``` TypeScript could end up trying a path like: `node_modules/my-pkg/styles.css/package.json` or `node_modules/my-pkg/styles.css/a/b/package.json`. This depends on how the module resolution executes, and how the module is referenced. In the example above though, TypeScript checks if the files exist. Our update logic delegates this check to our virtual file system. The virtual file system currently would throw an error by accident as it walks up the path and discovers that `styles.css` is not a directory, _but_ a file. This results in an error as seen in angular#22919. Fixes angular#22919.
devversion
force-pushed
the
schematics-fix-is-directory
branch
from
June 15, 2021 19:42
0515044
to
d61ca54
Compare
wagnermaciel
pushed a commit
that referenced
this pull request
Jun 16, 2021
TypeScript resolves modules using a rather complicated module resolution algorithm. The algorithm tries various paths to determine a possible entry-point for a module. e.g. it also respects a containing `package.json` file, or respects the closest `node_modules` parent directory. In some situations, TypeScript could end up trying a path where a parent directory segment resolves to an existent file. e.g. consider the following directory structure: ``` node_modules/my-pkg/package.json node_modules/my-pkg/styles.css ``` TypeScript could end up trying a path like: `node_modules/my-pkg/styles.css/package.json` or `node_modules/my-pkg/styles.css/a/b/package.json`. This depends on how the module resolution executes, and how the module is referenced. In the example above though, TypeScript checks if the files exist. Our update logic delegates this check to our virtual file system. The virtual file system currently would throw an error by accident as it walks up the path and discovers that `styles.css` is not a directory, _but_ a file. This results in an error as seen in #22919. Fixes #22919. (cherry picked from commit 805d3ae)
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
cla: yes
PR author has agreed to Google's Contributor License Agreement
target: patch
This PR is targeted for the next patch release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TypeScript resolves modules using a rather complicated module
resolution algorithm. The algorithm tries various paths to
determine a possible entry-point for a module. e.g. it also
respects a containing
package.json
file, or respects the closestnode_modules
parent directory.In some situations, TypeScript could end up trying a path where
a parent directory segment resolves to an existent file. e.g.
consider the following directory structure:
TypeScript could end up trying paths like:
node_modules/my-pkg/styles.css/package.json
ornode_modules/my-pkg/styles.css/a/b/package.json
. This depends on howthe module resolution executes, and how the module is referenced.
In the example above though, TypeScript checks if the files exist. Our update
logic delegates this check to our virtual file system. The virtual file
system currently would throw an error by accident as it walks up the
path and discovers that
styles.css
is not a directory, but a file (https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/src/tree/host-tree.ts#L321)This results in an error as seen in
#22919. This seems to have been introduced
accidentally with #21161.