bluwy/publint

Suggest adding `"type"` field to all packages

Closed this issue ยท 3 comments

Hi there, I was reading through the Node v20.10.0 release notes and noticed the following regarding experimental CJS/ESM detection:

We hope to make detection enabled by default in a future version of Node.js. Detection increases startup time, so we encourage everyone โ€” especially package authors โ€” to add a type field to package.json, even for the default "type": "commonjs". The presence of a type field, or explicit extensions such as .mjs or .cjs, will opt out of detection.

I'm wondering if it would be a good idea for publint to recommend that all packages have a "type" field, since it seems Node will shift away from "commonjs" as the default. I'd imagine this would be a suggestion rather than a warning.

bluwy commented

I think that makes sense ๐Ÿ‘ It might be safer to wait till node v22 to see if they're settled on it before implementing it here. It's going to suggest that for a lot of packages.

I'll add this as an enhancement for now, and when v22 lands (around April/May 2024) we can implement it.

I think that makes sense ๐Ÿ‘ It might be safer to wait till node v22 to see if they're settled on it before implementing it here. It's going to suggest that for a lot of packages.

I'll add this as an enhancement for now, and when v22 lands (around April/May 2024) we can implement it.

Hi @bluwy , just letting you know this was also just added to Node v20.10.0 - I've updated the post above to link to the new release notes.

bluwy commented

Ah neat. If it's already in node 20 (LTS), then it seems like there's a good reason to push towards it now.