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

Publint doesn't respect excluded subfolders in the exports #105

Open
filipsobol opened this issue Jul 17, 2024 · 1 comment
Open

Publint doesn't respect excluded subfolders in the exports #105

filipsobol opened this issue Jul 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@filipsobol
Copy link

In our project we have a dist folder with ESM builds for use in projects using npm. Additionally, in dist/browser we have ESM and UMD builds that can be used directly in the browser.

Since we have "type": "module" in package.json, publint throws an error if the file containing require() doesn't have the .cjs extension. However, UMD uses require() and we don't want to change the extension to .cjs, because it won't work in the browser.

Since we use the exports field, I tried using Subpath patterns, which allows you to exclude "private" subfolders using the null target like this:

{
  "exports": {
    "./*": "./dist/*",
    "./browser/*": null
  }
} 

With this configuration, I can't get into the browser folder. However, publint doesn't respect the second rule and throws the following error:

pkg.exports["./*"] matches ./dist/browser/<FILENAME>.umd.js and is written in CJS, but is interpreted as ESM. Consider using the .cjs extension, e.g. ./dist/browser/<FILENAME>.umd.cjs
@bluwy
Copy link
Owner

bluwy commented Jul 18, 2024

Thanks! Yeah it doesn't handle null well yet, so this is a bug 👍

@bluwy bluwy added the bug Something isn't working label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants