yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
339 stars 118 forks source link

Support for Vite.js #40

Closed philippkuehn closed 3 years ago

philippkuehn commented 3 years ago

Describe the bug When using the next generation esm bundler vite, I'm getting this error:

 > node_modules/y-prosemirror/src/lib.js:1:26: error: No matching export for import "ProsemirrorMapping"
    1 │ import { updateYFragment, ProsemirrorMapping } from './plugins/sync-plugin.js' // eslint-disable-line
      ╵                           ~~~~~~~~~~~~~~~~~~

I think this is because ProsemirrorMapping is a type generated in the build process. Since vite (esbuild) is very strict and uses the source files, it can't find this export. Here is a comment from evan you about that.

Do you have any idea how to fix that on your side?

To Reproduce

  1. import y-prosemirror in a vite project
  2. start dev server
  3. See error

Expected behavior It should not throw an error

holtwick commented 3 years ago

I experienced the same problem. A fix would be great, thanks.

holtwick commented 3 years ago

I provided a PR that fixes the issue.

dmonad commented 3 years ago

Fixed this in y-prosemirror@1.0.7

holtwick commented 3 years ago

Thanks @dmonad Your patch works.