Fable: [fable-standalone] npm package

Created on 19 Feb 2019  路  9Comments  路  Source: fable-compiler/Fable

Isn't the dist too big? Shouldn't the dist be just the (one file) bundle?

All 9 comments

We're not paying for disk space in npm so I hope it's fine :)

At the beginning I was thinking to have a separate package for the web worker bundle, but at the end I merge them to avoid the need of having to republish the two packages every time.

I think there's value in keeping at least the commonjs files and the worker because:

  • It's much easier to debug the commonjs files from a node app
  • The worker bundle contains also extra code: the Worker.fsproj but also the Babel bits. I noticed we don't need to load the whole standalone package and if we bundle only the parts we need from babel-core with a simple trick and tree-shaking, we can save many bytes (I forgot the exact number but I think it was around 500KB).

We could remove the "es2015" folder. Or we could rename the files in there to .mjs and use them in node. I think the latest version already supports import syntax (with that extension).

@alfonsogarciacaro My mistake, I probably misunderstood the purpose of the standalone package, it's supposed to be dev dependency to use to build and minimize and treeshake your projects (e.g. fable-compiler-js etc.), not a pre-minified pre-shaken dependency (it's too big for that).

Well, at the moment is doing the two functions: dev dependency for fable-compiler-js and production-ready minified bundle when used as a web worker. We can split the web worker into a separate package. But it may complicate a bit building, package distribution and the steps to make the REPL work.

IMO fable-standalone should only contain the minimized bundle, to be used by both the web worker and fable-compiler-js (as it did before, no reason not to). Currently the fable-standalone npm dist size is over 32 MB, entirely self-defeating the awesome fact that Fable manages to squeeze itself (including almost the entire FCS) into 3.7 MB (unzipped) vs 15 MB just for FCS in fable-cli.

For debugging purposes, there is the bench-compiler in fable-standalone/test which is the exact same thing as fable-compiler-js, but is compiled from source and can be run on either .net or node.js.

@alfonsogarciacaro I can take a stab at switching the web worker (and fable-compiler-js) to use the minimized bundle, unless you prefer to do that yourself.

From that perspective, you're right 馃 Yes, please give it a go. I guess we can put the FCS+Fable bundle and the worker bundle (including the Babel bits) side by side (so it's easier to copy them later for the REPL). For the worker I guess you just need this line: https://github.com/fable-compiler/Fable/blob/027307bf9f56fc22aa43b63cb5e19f3f24d1f3da/src/fable-standalone/src/Worker/Worker.fs#L50

And probably also add externals configuration to the worker webpack.config so it doesn't touch the already minified bundle.

@alfonsogarciacaro Yes, I believe that's how it was in the repl before.

Before we used importScripts as is in the worker: https://github.com/fable-compiler/repl/blob/2ee104d6c4fd3cc854bcb9760719bfa862f635d3/src/Worker/Worker.fs#L12

But this forces you to expose the Fable bundle with a global name: https://github.com/fable-compiler/repl/blob/2ee104d6c4fd3cc854bcb9760719bfa862f635d3/src/Worker/Worker.fs#L54-L56

Not the end of the world, but we probably can avoid that with some webpack configuration :)

Closing as solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomcl picture tomcl  路  4Comments

jwosty picture jwosty  路  3Comments

MangelMaxime picture MangelMaxime  路  3Comments

et1975 picture et1975  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments