Closed jbms closed 4 years ago
Hi, thanks for opening the issue. Yes, Node's conditional exports are not well supported by blunders currently (unfortunately). There is an issue here fore rollup, but it seems like it's landed in Webpack 5 from what I've been able to find.
Each codec is bundled separately using code splitting, and is the default export from module, so the import shouldn't have the brackets.
import Blosc from 'numcodecs/blosc';
// not { Blosc }
I'm not sure if webpack has tree-shaking, but it shouldn't have a hard time doing so. The main entry point is just exporting each of the separate codecs.
If you continue to have issues with configuring webpack, you can import the esm module for blosc directly:
import Blosc from './node_modules/numcodecs/dist/blosc.mjs';
From node.js it is possible to import just a single codec, but this does not seem to work from a browser-targeted build using typescript/webpack. Typescript gives the error:
Using
works but also pulls in pako, which increases the bundle size a fair bit.