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

Add conditional exports to package.json #815

Merged
merged 2 commits into from
Mar 14, 2025

Conversation

lukescott
Copy link
Contributor

@lukescott lukescott commented Mar 6, 2025

I'm in the process of updating to Node 22 and I ran into an issue with the default export not working:

src/signature.tsx:25:18 - error TS2351: This expression is not constructable.
  Type 'typeof import("./node_modules/signature_pad/dist/types/signature_pad")' has no construct signatures.

25   this.pad = new SignaturePad(this.canvas, {

This PR fixes compatibility with TypeScript's "nodenext" module resolution. The "module" property is non-standard and not supported by node. The official way is "Conditional Exports":

https://nodejs.org/docs/latest-v22.x/api/packages.html#conditional-exports

This is needed for packages that support CommonJS and ESM where the "type" is omitted or set to "commonjs".

(Note: "require" could be omitted, but I was more explicit including both "require" and "default")

package.json Outdated
"exports": {
"import": "./dist/signature_pad.js",
"require": "./dist/signature_pad.umd.js",
"default": "./dist/signature_pad.umd.js",
Copy link
Collaborator

@UziTech UziTech Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it has a problem with the trailing comma in this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Collaborator

@UziTech UziTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 💯

@UziTech UziTech merged commit 005a090 into szimek:master Mar 14, 2025
5 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 14, 2025
## [5.0.5](v5.0.4...v5.0.5) (2025-03-14)

### Bug Fixes

* Add conditional exports to package.json ([#815](#815)) ([005a090](005a090))
Copy link

🎉 This PR is included in version 5.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants