microsoft / microsoft/TypeScript
Allow specifying regex for module alias paths
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
alias regex, import alias regex, regex
Suggestion
Allow specifying path alias using regex with match replacement.
Use Cases
Using path alias when they are automatically generated by custom script in webpack or more fine grained control over path resolution with more complex directories. Current approach does not allow having dynamic alias which consists of 1 or more intermediate path variables.
Examples
Having this path: <projectDir>/modules/Users/resources/js should be resolvable with a regex, e.g.
RegEx: ^#(.+?)\/(.*)$
Resolve: ./modules/$1/resources/js/$2
So that importing from '#Users/manage' would be resolved to modules/Users/resources/js/manage(.ts|.js) etc..
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by locating TypeScript's existing path-alias and module-resolution handling, then compare it with the regex capture and replacement examples in the issue. Add coverage for resolving '#Users/manage' while preserving current alias behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, webpack
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100