steveruizok / perfect-freehand

Draw perfect pressure-sensitive freehand lines.
https://perfectfreehand.com
MIT License
4.48k stars 156 forks source link

[Bug] Explicit ESM declaration #53

Closed Redemption198 closed 2 years ago

Redemption198 commented 2 years ago

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 commented 2 years ago

Awesome, want to make a PR?

Redemption198 commented 2 years ago

Awesome, want to make a PR?

Sure. It's here https://github.com/steveruizok/perfect-freehand/pull/55

Ursuss21 commented 11 months ago

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 commented 6 months ago

This has been released. v1.2.2