Should main and module field values in package.json be switched?
See original GitHub issueIn my project which employs Babel, Jest tests which passed before I started using your package are now failing with a message indicating that the code from your package is not plain JavaScript. In your package.json
, the module
field is set to "dist/es5/index.js"
, which I believe uses CommonJS modules, while main
is set to "dist/index.js"
, which employs standard JavaScript modules. Reading this proposal describing how the module
field allows opt-in use of standard JavaScript modules (while still providing access to CommonJS modules through main
), I feel that these two field values should be switched. And indeed, when I switch them, my tests pass again.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Should main and module field values in package.json be switched ...
In your package.json , the module field is set to "dist/es5/index.js" , which I believe uses CommonJS modules, while main is set to...
Read more >What is the "module" package.json field for? - Stack Overflow
The main field makes sure that Node users using require will be served the UMD version. The module field is not an official...
Read more >package.json vs package-lock.json: Major Differences
The package.json and package-lock.json files are crucial for node packages. Let's explore how package-lock.json differs from package.json, ...
Read more >The Basics of Package.json - NodeSource
The main property json is a direction to the entry point to the module that the package. json is describing. In a Node....
Read more >How To Use Node.js Modules with npm and package.json
This is the default value for a package. json 's main property, which is the point of entry for npm modules.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Switched to ng-packger. Everything should be standard now. (v5.2.0)
5.2.2 fixes the problem with the prod build. Thank you!