-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extract): makes support for subpath imports explicit (#855)
## Description - ensures that subpath imports are recognized as 'aliased', just like the webpack and tsconfig aliases & import paths. - splits out the 'aliased' dependency type into three (while leaving the 'aliased' one in place both for convenience and backwards compatibility): `aliased-subpath-import`, `aliased-webpack`, `aliased-tsconfig` - modifies the `moreThanOneDependencyType` rule/ matcher so ... - it doesn't count aliases as separate dependency types (see documentation for rationale) - it doesn't count `type-only` as separate dependency types (also: see documentation) TODO: subpath imports can resolve to local modules (`"#*": "./src/*"`), _but also_ to 3rd party modules (`"#aliasdash/*": "lodash/*"`) or even core modules (which should be considered a criminal offence and is currently not even recognized in enhanced-resolve: `"#path-but-aliased": "path"`). These should be added to the dependencyTypes array as well - will probably be in a separate PR, though. ## Motivation and Context [subpath imports](https://nodejs.org/api/packages.html#subpath-imports) work since node 12.9 (!) and are a vastly superior alternative to tsconfig paths other alias systems (in webpack, babel, ...): - there's native support for it in nodejs, typescript (recent versions) and most other bundler/ packager under the sun. - This means it doesn't require third party shims/ polyfills, which is good for site reliability. Dependency-cruiser already correctly resolved subpath imports - this PR ensures they're explicitly named as such. ## How Has This Been Tested? - [x] green ci - [x] additional automated non-regression tests - [x] updated automated non-regression tests ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation only change - [ ] Refactor (non-breaking change which fixes an issue without changing functionality) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change)
- Loading branch information
Showing
20 changed files
with
309 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.