dmonad / lib0

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

Point to cjs entrypoint from project main #8

Closed sammacbeth closed 4 years ago

sammacbeth commented 4 years ago

This fixes module imports on node, making require('lib0') work correctly.

dmonad commented 4 years ago

Similarly to y-protocols, this is also a esm module that works in nodejs >= v13. Similarly to your ticket here https://github.com/yjs/y-protocols/issues/3 cjs modules should import the lib0/dist/[X].cjs file instead of lib0/[X].js. In my projects I simply overwrite the import path (see rollup.config.js) when I transform a module to cjs.

Furthermore, the index.js export is not yet fully supported. Some of the modules have side effects that force bundlers to include unnecessary functions. My recommendation for now (and probably also for the future) is to import the module files directly.