.mjs and .cjs extensions for ESM and CJS aren't supported.
Dual package
My related issue: mongodb-js/ejson-shell-parser#157
Steps to reproduce
yarn init -y
yarn add @preconstruct/cli
- add in
package.json
"main": "dist/<PROJECT_NAME>.cjs",
"module": "dist/<PROJECT_NAME>.mjs",
"exports": {
"import": "./dist/<PROJECT_NAME>.mjs",
"require": "./dist/<PROJECT_NAME>.cjs"
}
- create an empty
src/index.js file
yarn preconstruct build
🎁 error <PROJECT_NAME> main field is invalid, found `"dist/<PROJECT_NAME>.cjs"`, expected `"dist/<PROJECT_NAME>.cjs.js"`
🎁 error <PROJECT_NAME> module field is invalid, found `"dist/<PROJECT_NAME>.mjs"`, expected `"dist/<PROJECT_NAME>.esm.js"`
🎁 info Some of the errors above can be fixed automatically by running preconstruct fix
🎁 info If you want to learn more about the above error, check https://preconstruct.tools/errors
🎁 info If the error is not there and you want to learn more about it, open an issue at https://github.com/preconstruct/preconstruct/issues/new
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
<PROJECT_NAME> is field name of package.json
.mjsand.cjsextensions for ESM and CJS aren't supported.Dual package
My related issue: mongodb-js/ejson-shell-parser#157
Steps to reproduce
yarn init -yyarn add @preconstruct/clipackage.jsonsrc/index.jsfileyarn preconstruct build<PROJECT_NAME> is field name of package.json