Boshen @boshen.github.io 路 May 20

Is there a resource for publishing dual cjs esm packages, where you mark a subdirectory module type with a package.json file? Here is my understanding, but may be wrong. github.com/oxc-project/...

8 likes 6 replies

?

Replies

Corbin Crutchley 路 May 20

CCing the super pro @acemarke.dev

Nicolas Dubien 路 May 20

I've been using this trick for fast-check.dev 馃槄 But not sure where I found it

Jeppe Reinhold 馃嚛馃嚢 路 May 20

Multiple package.json files in package subpaths is not a thing, that sounds like a huge misunderstanding of the spec. This is exactly what the export conditions are made for.

Emanuele (Ema) 路 May 20

nodejs.org/docs/latest/... Not sure if it helps

Nicol貌 Ribaudo 路 May 20

For a real-world example look at the @babel/runtime package. - it uses cjs by default - in helpers/esm/package.json, it marks files inside helpers/esm as being esm

James 路 May 20

some of this is the result of tooling iirc some tools produce dual packages by making a 2nd `package.json` for sake of running tsc with the right `type` set. they should clean that up, but it often gets published i may be hallucinating this (maybe im an LLM) but im pretty sure thats where its from