gtgalone / react-quilljs

React Hook Wrapper for Quill, powerful rich text editor.
https://www.npmjs.com/package/react-quilljs
MIT License
248 stars 28 forks source link

ESM should use dynamic import instead of require #83

Closed steven-resonance closed 4 months ago

steven-resonance commented 5 months ago

The library is working great! But, when running tests with vitest, the imports are breaking for two reasons.

  1. vitest uses Node module resolution, which ignores module, so to tell an ESM based project to use esm/index.js during testing, you must include the exports property in package.json. An example of how that would look is below.
  2. There is a require('quill') in esm/index.js, which still causes resolution to break in ESM environments. This would need to be changed to a dynamic import (import('quill')).
  "exports": {
    "require": "./lib/index.js",
    "import": "./esm/index.js",
    "default": "./lib/index.js"
  },
frontendpm commented 5 months ago

have the same issue!

gtgalone commented 4 months ago

@steven-resonance @frontendpm Thanks Please update to 2.0.1