Open JamesMGreene opened 7 years ago
Once this is in place, we should also be able to eliminate the "browser-version/browser-specific/lib/customUtils.js" file since we can tree-shake out the use of the crypto
module to just its randomBytes
function.
Trying to do so now results in the following nasty file size increases:
nestdb
current (with a few local changes):
nestdb
current (with a few local changes), minus the browser-specific "customUtils.js":
So its existence is currently DEFINITELY warranted! :confused:
FYI on NeDB (pre-fork) stats:
nedb@1.8.0
:
ES6 module syntax offers some awesome benefits when it comes to building a streamlined browser version of your module by leveraging tools like Rollup that can perform advanced reduction of dependencies by a methodology called tree shaking.
This should greatly reduce the size of the current browser version as it should strip out a lot of unused dependency methods from the bundled version.
It is important to note that not all tree-shaking implementation are created equal. Currently, Webpack 2's implementation leaves more dead code intact (before uglification) than Rollup's does.
Rollup can also be utilized as a plugin for
browserify
with therollupify
plugin. Combine that with thebabelify
plugin to make ES5-compatible output modules. See Rollup's publishing tips for guidance on how to capitalize on both ES6 and ES5 formats.