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

Invalid .mjs and .cjs extensions #576

Open
rtritto opened this issue Jul 29, 2023 · 0 comments
Open

Invalid .mjs and .cjs extensions #576

rtritto opened this issue Jul 29, 2023 · 0 comments

Comments

@rtritto
Copy link

rtritto commented Jul 29, 2023

.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

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

No branches or pull requests

1 participant