Absolute base url calculated relative to running code, not tsconfig path
See original GitHub issueI have this app structure
tsconfig.json
shared/
services/
service1/
index.js
with
const tsConfig = require('../../tsconfig.json');
const tsConfigPaths = require('tsconfig-paths');
tsConfigPaths.register({
baseUrl: tsConfig.compilerOptions.baseUrl,
paths: tsConfig.compilerOptions.paths
});
inside index.js tsconfig basUrl configured as
"baseUrl": "./services/",
"shared/*": [ "../shared/*" ]
to allow imports like import {} from 'service1/smth'
but tsconfig-paths
makes wrong absolute path for this baseUrl
configLoaderResult { resultType: 'success',
absoluteBaseUrl: '.../services/service1/services/',
instead of just .../services/
https://github.com/jonaskello/tsconfig-paths/blob/master/src/config-loader.ts#L35
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Absolute path in the tsconfig doesn't work - node.js
Update the tsconfig.json file with the following options: ... of entries which re-map imports to lookup locations relative to the 'baseUrl'.
Read more >Documentation - Module Resolution - TypeScript
value of baseUrl property in 'tsconfig.json' (if given path is relative, it is computed based on the location of 'tsconfig.json'). Note that relative...
Read more >tsconfig-paths - npm
Either absolute or relative path. If relative it's resolved to current working directory. const cleanup = tsConfigPaths.register({ baseUrl, ...
Read more >Typescript: How to auto import with absolute paths if baseUrl ...
In my tsconfig.json I have set a base url: "baseUrl": "src/app", ... WebStorm calculates import paths relative to "baseUrl" specified in ...
Read more >Typescript paths with ts-node, ts-node-dev and Jest | Medium
To achieve the non-relative import mentioned above, tsconfig.json could look like this: From the TypeScript docs: baseUrl: Specify the base ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve made an implementation of this in the commit https://github.com/jonaskello/tsconfig-paths/commit/cb18815b80374a6c071061bb8d92fc52b35c69e0
I have just quickly tested it and it seems to work. I’ll release it when i have more time to verify. But please try it out.
Fixed in 2.2.0