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
Usage with node not compatible with "outDir" #75
Comments
As a workaround, I've created this alternative register file. const tsConfig = require("./tsconfig.json");
const tsConfigPaths = require("tsconfig-paths");
const path = require("path");
tsConfigPaths.register({
baseUrl: path.resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''),
paths: tsConfig.compilerOptions.paths
}); Thanks for the public api! Love those things! |
@nicojs your snippet does not work for cases like this: tsconfig.json: "outDir": "dist",
"baseUrl": ".",
"paths": {
"@logger": [ "src/lib/logger" ]
},
... |
@swiatek25 try something like this: const tsConfig = require('./tsconfig.json');
const tsConfigPaths = require('tsconfig-paths');
const { baseUrl, outDir, paths } = tsConfig.compilerOptions;
const outDirPaths = Object.entries(paths).reduce(
(outDirPaths, [k, v]) => Object.assign(
outDirPaths,
{ [k]: v.map(path => path.replace(/^src\//, `${outDir}/`)) }
),
{}
);
tsConfigPaths.register({ baseUrl, paths: outDirPaths }); |
See #114 |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, it seems that tsconfig-paths is not compatible with the
"outDir"
compiler option.For example:
Reproduction steps:
Find files here:
tsconfig-paths-outDir.zip
after you've created the project, use these commands:
Proposal
I propose either to use the
outDir
by default (breaking for ts-node users) or create a separateregister
hook for node js scenario's.The text was updated successfully, but these errors were encountered: