-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: infer aliases from tsconfig.json #494
base: main
Are you sure you want to change the base?
Conversation
…unbuild into feat/infer-alias-from-tsconfig
…unbuild into feat/infer-alias-from-tsconfig
…unbuild into feat/infer-alias-from-tsconfig
…unbuild into feat/infer-alias-from-tsconfig
@@ -15,6 +23,7 @@ export const DEFAULT_EXTENSIONS: string[] = [ | |||
|
|||
export function resolveAliases(ctx: BuildContext): Record<string, string> { | |||
const aliases: Record<string, string> = { | |||
...inferAliasesFromTsconfig(ctx), |
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 should be opt-in
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.
Yes, do you suggest adding a new configuration for this feature?
findConfigFile, | ||
readConfigFile, | ||
parseJsonConfigFileContent, | ||
} from "typescript"; |
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.
We should avoid loading typescript
package as it adds runtime overhead.
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.
I have considered this issue and come up with two alternative solutions:
-
Implement a lightweight
tsconfig.json
parsing logic that only parses thepaths
andbaseUrl
fields to infer the alias. -
Use a lightweight alternative library (e.g., https://github.com/privatenumber/get-tsconfig) (or implement one ourselves) to parse the complete
tsconfig.json
configuration, which can not only be used for alias inference but also for other configurations, such as automatically passing it to esbuild'stsconfigRaw
(which can resolve Decorators support #309), thereby eliminating the need to duplicate existing content fromtsconfig.json
in configuration files.
I'd love to hear your feedback! 🤔
resolves #489
resolves #428