gtgalone / react-quilljs

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

ESM should use dynamic import instead of require #83

Open steven-resonance opened 1 week ago

steven-resonance commented 1 week 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 1 week ago

have the same issue!