-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow imports with mapped paths to generate resolved path in require() #32218
Comments
It appears that issue #22908 tracks a similar request. To be clear: I am only asking for a compiler option to force modules resolved with mapped paths be converted to the full relative path to the module. This would allow compiled code which requires mapped modules to just work. Modules imports resolved with mapped paths are then just a form of short hand. |
@ToddThomson The whole world, except MS, expects a resolved path... |
I have a proposal for this feature. As @DanielRosenwasser said in #10866:
If paths are resolved by TS, the bundler on top of it would get confused since it's expecting an aliased path and isn't getting it. This is obviously a needed feature and the default (current) behavior shouldn't change. However, resolving those paths has its use cases - basically whenever you don't use a bundler. In my case, I need this functionality even with a bundler - I need ProposalWe can have a |
I'm really glad this got brought up again after @DanielRosenwasser closed #10866. This is such a simple feature that will help many who aren't using bundlers for application such as nodejs backends. Even if I had a bundler, I would have to tell it what I'm not sure, though, that I want to resolve all of my tsconfig.json Proposal 1Have a // tsconfig.json
{
"compilerOptions": {
"aliasResolvers": { <=
"@my-alias": "./src" <=
},
"baseUrl": ".",
"paths": {
"@my-alias": ["./src/*"]
{
}
} Proposal 2Add an optional object type to // tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@my-alias": {
"path": "./src/*",
"resolvesTo": "./src" <=
}
{
}
} |
@DanielRosenwasser Can you please link the duplicate open issue? |
I am using an import within a Ts source file:
This import gets resolved correctly:
In the tsconfig.json, I have:
The require() in the compiled js output is:
I expected that this would be resolved to the full relative path.
This causes grief in mocha test resolution as the "@TsToolsCommon/Utils/TsCore" module cannot be found.
The text was updated successfully, but these errors were encountered: