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

feat: explicitly include type #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benmccann
Copy link

@benmccann benmccann commented Sep 18, 2024

I've read through several issues in both npm/cli and npm/rfcs and there seems to be universal agreement that adding "type": "commonjs" would be an improvement as it's better to explicit than implicit both for understandability and to improve performance by eliminating the need to go down detection code paths.

Several people have also suggested prompting for the type field and that is much more controversial and has been decided against, so I have not done that.

References

npm/rfcs#75 (comment)

From https://nodejs.org/en/blog/release/v20.10.0:

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".

https://publint.dev/ and the publint package also validate that the type field is present and warn package authors if it is not. It would be best to create a package.json without warnings out of the box: https://github.com/bluwy/publint/blob/master/site/rules.md#use_type

@benmccann benmccann requested a review from a team as a code owner September 18, 2024 16:11
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.

1 participant