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

ESM package + TypeScript support #435

Open
ntucker opened this issue Apr 20, 2022 · 0 comments
Open

ESM package + TypeScript support #435

ntucker opened this issue Apr 20, 2022 · 0 comments

Comments

@ntucker
Copy link

ntucker commented Apr 20, 2022

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.

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

1 participant