staltz / callbag-basics

👜 Tiny and fast reactive/iterable programming library
MIT License
1.65k stars 43 forks source link

callbag-flatten exports default #21

Open jorbuedo opened 6 years ago

jorbuedo commented 6 years ago

Following the build it yourself philosophy of this library, I made my own lib of callbags. Just a package.json with the dependencies I need and an index.js exporting them like the one in this project.

However I noticed callbag-flatten failed to work, because the new version doesn't export the function like the rest of the callbags. Now it needs to be flatten: require('callbag-flatten').default, instead of the previous flatten: require('callbag-flatten')

I wonder, shouldn't all calbags export the same way?

staltz commented 6 years ago

It should

niieani commented 2 years ago

Confirming this is an issue. callbag-flatten is not CommonJS but a module, which means the correct export is, as @jorbuedo pointed out, called default. Importing flatten from the current version of callbag-basics results in importing a module, rather than the function.

Webpack behaves closer to spec and fails, but when compiled with esbuild this works. So your milage may vary. But it should be corrected, either here, or upstream in callbag-flatten.

Recommended workaround is to use callbag-flatten installed directly.