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 with allowJS and absolute imports fails at runtime #469

Closed
novascreen opened this issue Aug 31, 2019 · 0 comments · Fixed by #470
Closed

TypeScript with allowJS and absolute imports fails at runtime #469

novascreen opened this issue Aug 31, 2019 · 0 comments · Fixed by #470

Comments

@novascreen
Copy link
Contributor

I've created a repo to reproduce this issue:
https://github.com/novascreen/ncc-ts-allowjs

TypeScript is configured to allowJS, which we need in a project we are transitioning over to TS gradually. We also have baseUrl/paths configured to be able to do absolute imports of modules in src.
The ncc build runs fine and absolute imports of TS files work perfectly, but when running the output we get a Cannot find module for a JS file we tried to import using an absolute import.

In summary:

  • relative TS import: ✔
  • absolute TS import: ✔
  • relative JS import: ✔
  • absolute JS import: ❌

I would expect this to either work or hope to get at least an error during build. We can work around this using relative imports for the JS files, but it's easy to accidentally forget and then get a runtime error once the app is built and deployed 😬

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

Successfully merging a pull request may close this issue.

1 participant