fflate is currently triple-packaged:
- ESM
- UMD
- ESM (browser bundle)
This means the install size (on disk) and the tarball size (over the wire) are increased quite a lot due to duplication.
It'd be really nice if we could move to only shipping ESM, i.e. no bundles, no minification, one file and one set of types.
Correct me if I'm wrong, but it seems the following is true:
- UMD doesn't seem necessary anymore since all runtimes (browsers and node alike) can run ESM
- The browser bundle only exists as a way of injecting a browser-friendly worker
- The main build output contains a node-only worker
- All LTS of Node support ESM and
require(esm) (i.e. even CJS consumers can import ESM)
That means the main blocker is how to still have two worker flavours without needing two bundles... but I think we can solve that through package exports:
{
"exports": {
".": "./lib/index.mjs",
"./node": {
"default": "./lib/node-index.js"
}
}
}
then index and node-index import different workers but use the same underlying logic (imported, not duplicated)
With this, we can then just tsc the whole thing one time. No bundlers or minifiers needed anymore.
EDIT: had a stab at this in a branch and its doable. fiddly because we have to unravel the rewriteBuilds stuff, exports, etc. but seems doable and cleans a lot up
fflateis currently triple-packaged:This means the install size (on disk) and the tarball size (over the wire) are increased quite a lot due to duplication.
It'd be really nice if we could move to only shipping ESM, i.e. no bundles, no minification, one file and one set of types.
Correct me if I'm wrong, but it seems the following is true:
require(esm)(i.e. even CJS consumers can import ESM)That means the main blocker is how to still have two worker flavours without needing two bundles... but I think we can solve that through package exports:
then
indexandnode-indeximport different workers but use the same underlying logic (imported, not duplicated)With this, we can then just
tscthe whole thing one time. No bundlers or minifiers needed anymore.EDIT: had a stab at this in a branch and its doable. fiddly because we have to unravel the rewriteBuilds stuff, exports, etc. but seems doable and cleans a lot up