Elderjs/elderjs

Tree shaking, removal of unused/dead code

cayolblake opened this issue · 1 comments

@nickreese for the life of me I'm not able to find a way to use Terser/Uglify to do treeshaking, or remove any JavaScript code that is not used, sometimes called dead code, for builds.

In terser (which supports ES6) for example, compress: {defaults: false, dead_code: true, unused: true} which ends up removing both unused and dead code, in addition to https://rollupjs.org/guide/en/#tree-shaking

Where/How to do it? 🤷

Elderjs does include terser in its default config:

import { terser } from 'rollup-plugin-terser';

It is only used on production builds:
const production = process.env.NODE_ENV === 'production' || !process.env.ROLLUP_WATCH;

if (production) {
config.plugins.push(
babel({
extensions: ['.js', '.mjs', '.cjs', '.html', '.svelte'],
include: ['node_modules/**', 'src/**'],
exclude: ['node_modules/@babel/**'],
runtimeHelpers: true,
}),
);
// terser on prod
config.plugins.push(terser());
}