-
Notifications
You must be signed in to change notification settings - Fork 12
Npm Size Reduction
spessasus edited this page Oct 15, 2024
·
2 revisions
The npm package works slightly differently than the standard install.
The library contains a lot of other functionality than just the synthesizer, which probably most people are going to use. This is wasted bandwith.
This is a problem, because it will be bundled by default when using bundlers such as webpack.
The solution is to use "tree shaking".
For example, webpack.config.js
;
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
// this enables tree shaking
sideEffects: false
}
]
},
mode: 'production',
};
This prevents unused modules from being included when not necessary.
Tip
If you encounter any errors in this documentation, please open an issue!
Warning
Make sure you always update worklet_processor.min.js
along with the npm package!