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

Specify type field in package.json #192

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Specify type field in package.json #192

merged 1 commit into from
Jan 17, 2024

Conversation

mattt
Copy link
Member

@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
10 checks passed
@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.

None yet

2 participants