Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree shaking, removal of unused/dead code #252

Open
cayolblake opened this issue Sep 24, 2022 · 1 comment
Open

Tree shaking, removal of unused/dead code #252

cayolblake opened this issue Sep 24, 2022 · 1 comment
Labels
question Further information is requested

Comments

@cayolblake
Copy link

cayolblake commented Sep 24, 2022

@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? 🤷

@eight04
Copy link
Contributor

eight04 commented Nov 4, 2022

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());
}

@eight04 eight04 added the question Further information is requested label Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants