DEV Community

Discussion on: How to start a TypeScript project [2021]

yoursunny profile image
Junxiao Shi

It ain't 2021 edition if TypeScript is not configured to emit ES Modules.
The leading JavaScript coder, @sindresorhus , is switching all the packages to ESM-only.
If you create CommonJS project, you can't import his packages anymore.

craigaholliday profile image
Craig Holliday Author

What’s a good post from them showing how to configure ESM-only and what does backwards compatibility look like?

yoursunny profile image
Junxiao Shi

I wish I know!
My own library is ESM only since (almost) the beginning, but all my dependencies are either ESM+CJS or CJS-only.

I went through significant efforts making all these things happy:

  • Node
  • TypeScript
  • Jest
  • webpack
  • Parcel bundler
  • Puppeteer

Now @sindresorhus went ESM-only, and Jest is throwing errors.

pcjmfranken profile image
Peter Franken

The leading JavaScript coder [...] you can't import his packages anymore

Businesses don't care about this at all, not even a little bit.

Dev wants to convert to ES Modules only > manager requests time/cost estimate > dev puts together gigantic list of internal codebases that would have to be converted > manager asks "and all that work only so you can write import x from x, instead of x = require(x) and use packages from your internet hero? No..."