-
Notifications
You must be signed in to change notification settings - Fork 104
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
paths are not being rewritten after compilation #222
Comments
This package doesn't affect TypeScript compilation, and therefore the module paths are left as-is in the final compiled JavaScript. If you need to convert these (e.g. are unable to use the registration described below), you need to use a different solution. However, you can register the paths in runtime via this package by altering the |
For some reason, even registering "outDir": "./dist",
"baseUrl": "./src",
"paths": {
"@services/*": ["./services/*"],
},
"ts-node": {
"require": ["tsconfig-paths/register"]
}
|
Try setting TS_NODE_BASEURL=./dist env when running node... |
@kendallroth That would seem to mean that the plugin is unable to access the |
Ah, that is an excellent point, and I know that the TS config file was certainly not being copied during the build. However, we eventually decided to go with an approach during build step, simply to avoid having to have any typescript references or packages in the production environment. However, thanks for the answer, and I hope it can help someone else in the future! |
@kendallroth What approach did you take? I'm suffering from the same issue and at this point, I'm planning to just use ts-node in production. |
I used |
This was the easiest and most straight forward solution for my needs. Thanks @kendallroth ! |
@kendallroth big thx |
i was having this issue and this comment #222 (comment) resolved in conjunction with TS_NODE_PROJECT we use: |
No matter what I seem to try, the values defined in
paths
in mytsconfig.json
file are not being transformed bytsconfig-paths
, which results in node being unable to resolves any modules.Giving an example, where I would expect
@graphql-handlers
imports in my ts files to be converted tographql-handlers
in my compiled .js... but when you examine the output in thedist
folder, all of the paths still show@graphql-handlers
which renders node unable to run.tsconfig.json
package.json
index.ts
Run command:
rm -rf dist; npm run compile; node_modules/.bin/ts-node -r tsconfig-paths/register dist/index.js
Error output:
Looking at the compiled output in dist/index.js, @graphql-handlers has not been converted:
The text was updated successfully, but these errors were encountered: