Skip to content
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

Typescript paths alias doesn't resolve #266

Open
howagain opened this issue Jul 16, 2024 · 3 comments
Open

Typescript paths alias doesn't resolve #266

howagain opened this issue Jul 16, 2024 · 3 comments

Comments

@howagain
Copy link

Trying to use a shared tailwind config in an integrated Nx monorepo. The module resolution is all done with typescript path aliasing rather than package manager workspace module resolution. The shared tailwind config works just fine if I do a relative import ../../libs/shared-tailwind-config.ts but fails with a module failed to resolve if I have a path alias in my tsconfig of @tw: [/libs/shared-tailwind-config.ts]. I have included the postcss.config.ts file in my tsconfig.josn and VS code is able to recognize the import alias correctly in the file.

@brc-dd
Copy link
Contributor

brc-dd commented Jul 16, 2024

What are you using for TS support? jiti or tsx? tsx supports tsconfig paths, jiti supports custom JITI_ALIAS format.

@howagain
Copy link
Author

howagain commented Jul 16, 2024 via email

@brc-dd
Copy link
Contributor

brc-dd commented Jul 16, 2024

Vite is using v4 of this module -- ts-node stuff. Install ts-node and tsconfig-paths and configure it in your tsconfig.json - https://typestrong.org/ts-node/docs/paths


Here is a working example if you wanna try that out - https://stackblitz.com/edit/vitejs-vite-htrwaq?file=tsconfig.json,postcss.config.ts,src/foo.ts&terminal=dev

With vite 6, you'll be able to do this without any extra configuration. You'll just need to install tsx instead of ts-node.

The issue can probably be closed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants