Skip to content

Conversation

@mattt
Copy link
Contributor

@mattt mattt commented Jan 17, 2024

Related to #191

From publint.dev

Since Node.js v20.10.0, it introduces a new --experimental-default-type flag to flip the default module system from "CJS-as-default" to "ESM-as-default". If enabled, package.json without the "type" field will mean its descendant JS files to be interpreted as ESM instead of CJS, which may not work correctly.

While this only applies to files outside of node_modules, it's still recommended to set it up for future-proofing. And it also helps the --experimental-detect-module flag if enabled.

Hence, if you've not set the "type" field, you can explictly set it as "type": "commonjs" (default value), or migrate to "type": "module" and write in ESM completely if possible.

@mattt mattt requested a review from aron January 17, 2024 14:19
@mattt mattt merged commit ddef501 into main Jan 17, 2024
@mattt mattt deleted the mattt/cjs-package-type branch January 17, 2024 14:32
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

Successfully merging this pull request may close these issues.

3 participants