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

[Bug] Explicit ESM declaration #53

Closed
Redemption198 opened this issue Aug 20, 2022 · 4 comments · Fixed by #55
Closed

[Bug] Explicit ESM declaration #53

Redemption198 opened this issue Aug 20, 2022 · 4 comments · Fixed by #55
Labels
bug Something isn't working

Comments

@Redemption198
Copy link
Contributor

This module is being used by Drauu which has an integration with VueUse and can be used with Nuxt (Vue). Since Nuxt 3 uses Vite as a bundler by default and it only allows the use of ESM modules, when it tries to bundle perfect-freehand the following error occurs:

import { getStroke } from "perfect-freehand";
^^^^^^^^^
SyntaxError: Named export 'getStroke' not found. The requested module 'perfect-freehand' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'perfect-freehand';
const { getStroke } = pkg;

I was able to "fix" it by adding the following lines into the package.json inside node_modules:

"type": "module",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js"
}
}

I'm not sure if this may cause some problems that's why I'm opening an Issue

@steveruizok
Copy link
Owner

Awesome, want to make a PR?

@Redemption198
Copy link
Contributor Author

Awesome, want to make a PR?

Sure. It's here #55

@Ursuss21
Copy link

Hello, I have an issue connected to this one in here. I guess the only thing remaining to do is to release the current version, if that's not a big deal.

@garand
Copy link

garand commented Mar 7, 2024

This has been released. v1.2.2

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

Successfully merging a pull request may close this issue.

4 participants