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

Lint package configuration #401

Merged
merged 4 commits into from
Jan 13, 2024
Merged

Lint package configuration #401

merged 4 commits into from
Jan 13, 2024

Conversation

huozhi
Copy link
Owner

@huozhi huozhi commented Jan 13, 2024

Lint the package exports or main field configuration in package.json based on the package module type. Replace previous publint integration

For example you have a bad configuration package.json:

In this package, it's CJS by deafult, and have following issues:

  • require cannot reference to a ESM output
  • import cannot reference to a CJS output
{
  "exports": {
    ".": {
      "require": "./dist/index.mjs"
    },
    "./foo": {
      "import": "./dist/foo.js"
    }
  } 
}

bunchee will still build but warn you with message

⚠️ Cannot export `require` field with .js or .mjs extension in ESM package, only .cjs extensions are allowed
⚠️   ./dist/index.js
⚠️ Cannot export `import` field with .cjs extension in ESM package, only .js and .mjs extensions are allowed
⚠️   ./dist/foo.cjs
Exports  File           Size
 .     dist/index.js  42 B
 ./foo dist/foo.cjs   103 B

Closes #377
Closes #393

@huozhi huozhi marked this pull request as ready for review January 13, 2024 20:21
@huozhi huozhi merged commit 36aa3b0 into main Jan 13, 2024
3 checks passed
@huozhi huozhi deleted the improve/warn-require-js-esm branch January 13, 2024 20:23
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.

warn if type: module but uses require condition with js extension Replace publint
1 participant