filerjs / filer

Node-like file system for browsers
BSD 2-Clause "Simplified" License
623 stars 154 forks source link

Reduce size of filer.js #575

Open humphd opened 5 years ago

humphd commented 5 years ago
parcel build --global Filer src/index.js --out-file filer.min.js --detailed-report

✨  Built in 263ms.

dist/filer.min.js                            89.26 KB    155ms
├── src/filesystem/implementation.js         20.39 KB     10ms
├── node_modules/buffer/index.js             19.54 KB     11ms
├── node_modules/minimatch/minimatch.js       7.32 KB     11ms
├── src/shell/shell.js                        3.88 KB      4ms
├── lib/intercom.js                           3.76 KB      8ms
├── src/filesystem/interface.js               3.39 KB      3ms
├── src/providers/websql.js                   2.47 KB      3ms
├── lib/nodash.js                             2.35 KB      8ms
├── src/providers/indexeddb.js                2.17 KB      4ms
├── node_modules/path-browserify/index.js      2.1 KB      2ms
└── + 27 more assets

We're currently sitting at ~89K for our minified version. That's a lot. Looking at the bundle info above, a few things we could do here:

  1. Pull the Shell out into a separate file (3K + 7K = 10K). You don't always need it, so let's not always bundle it
  2. Reduce the size of implementation.js by moving to async/await and throwing away most of the callback code. We have tones of code that is just functions wrapped around checks err callbacks. If we used async/await instead, we'd just await in a try...catch.
  3. #569 to pull WebSQL out into a separate file (2K)
  4. #572 to remove nodash.js (2K)
humphd commented 5 years ago

#597 to switch away from our internal src/path.js

humphd commented 5 years ago

598 to switch from minimatch to picomatch