You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Building an ESM package ("type": "module") requires imports to contain a ".js" at the end. To make this work in TypeScript, you can import "myModule.js" and the real file is "myModule.tsx". One could simply use TSC then to compile properly. However, some of us like using babel for the compilation step.
Everything works fine in fact if I just add .js as the output files work perfectly. However, when I run something like jest it breaks.
Cannot find module './entities/Entity.js' from 'packages/normalizr/src/denormalize.ts'
(./entities/Entity.ts is the actual file)
Solution
It would be nice to have a simple way to either add ".js" extension for extensionless imports - or lookup other extensions when a ".js" exists in an import.
The text was updated successfully, but these errors were encountered:
Motivation
With TypeScript 4.7 the ESM world is getting serious: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#esm-nodejs
Building an ESM package ("type": "module") requires imports to contain a ".js" at the end. To make this work in TypeScript, you can import "myModule.js" and the real file is "myModule.tsx". One could simply use TSC then to compile properly. However, some of us like using babel for the compilation step.
Everything works fine in fact if I just add .js as the output files work perfectly. However, when I run something like jest it breaks.
Cannot find module './entities/Entity.js' from 'packages/normalizr/src/denormalize.ts'
(
./entities/Entity.ts
is the actual file)Solution
It would be nice to have a simple way to either add ".js" extension for extensionless imports - or lookup other extensions when a ".js" exists in an import.
The text was updated successfully, but these errors were encountered: