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

support absolute import with baseUrl #831

Closed
andriyor opened this issue Mar 8, 2024 · 1 comment
Closed

support absolute import with baseUrl #831

andriyor opened this issue Mar 8, 2024 · 1 comment

Comments

@andriyor
Copy link

andriyor commented Mar 8, 2024

I have tsconfig with such baseUrl
"baseUrl": ".",

transpilation produce such error:
Cannot find module 'src/hivemind/experiments' from 'src/components/invoices/invoices-page/invoice-banner.tsx'

@alangpierce
Copy link
Owner

Hi, sorry for the delay. Sucrase, like the official TypeScript compiler, doesn't modify import statements at transpile time. The idea is that you should write paths that work with your runtime (e.g. Node) or bundler (e.g. Webpack), and if you want something like absolute import, you should configure that in your runtime or bundler settings. The baseUrl TypeScript config (which Sucrase doesn't need) is so the TypeScript typechecker can match the runtime/bundler settings, but it isn't meant to change anything about runtime file resolution.

See the comments from the TypeScript team in this issue for the rationale: microsoft/TypeScript#26722

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