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
|
|
||
| export function resolveAliases(ctx: BuildContext): Record<string, string> { | ||
| const aliases: Record<string, string> = { | ||
| ...inferAliasesFromTsconfig(ctx), |
There was a problem hiding this comment.
Yes, do you suggest adding a new configuration for this feature?
| findConfigFile, | ||
| readConfigFile, | ||
| parseJsonConfigFileContent, | ||
| } from "typescript"; |
There was a problem hiding this comment.
We should avoid loading typescript package as it adds runtime overhead.
There was a problem hiding this comment.
I have considered this issue and come up with two alternative solutions:
-
Implement a lightweight
tsconfig.jsonparsing logic that only parses thepathsandbaseUrlfields 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.jsonconfiguration, 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.jsonin configuration files.
I'd love to hear your feedback! 🤔
resolves #489
resolves #428