dmonad / lib0

Monorepo of isomorphic utility functions
MIT License
347 stars 62 forks source link

Usage with webpack #10

Closed aulneau closed 4 years ago

aulneau commented 4 years ago

Hi there!

I am starting to use yjs, and ran into an issue with this library not being correctly used/transpiled by the bundling I'm using. The app is a next.js application, which uses webpack etc to bundle everything. I am trying to run the yjs function applyUpdate, which seems to have a dep somewhere on the binary lib in lib0.

This is the error I get:

TypeError: contentRefs[(info & lib0_binary_js__WEBPACK_IMPORTED_MODULE_17__.BITS5)] is not a function

Also when I have tried to import other libraries from lib0, I get similar errors.

Thanks so much!

dmonad commented 4 years ago

Hi @aulneau , can you please check what the value of lib0_binary_js__WEBPACK_IMPORTED_MODULE_17__.BITS5 is?

Also, what is the difference to https://github.com/yjs/yjs-demos ? All demos there use webpack as a bundler and it seems to work.

aulneau commented 4 years ago

@dmonad I think I figured out the issue. I was encoding my arrays incorrectly and passing them through, and when the contentRefs[(info & lib0_binary_js__WEBPACK_IMPORTED_MODULE_17__.BITS5)] tried to find the function for reading it, it failed. I'm going to close this. Thanks so much for all your work!