Elderjs / elderjs

Elder.js is an opinionated static site generator and web framework for Svelte built with SEO in mind.
https://elderguide.com/tech/elderjs/
MIT License
2.11k stars 53 forks source link

Tree shaking, removal of unused/dead code #252

Open cayolblake opened 1 year ago

cayolblake commented 1 year ago

@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 commented 1 year ago

Elderjs does include terser in its default config: https://github.com/Elderjs/elderjs/blob/162972ccdbad7f5569096bd5794cd59271c6004a/src/rollup/getRollupConfig.ts#L3 It is only used on production builds: https://github.com/Elderjs/elderjs/blob/162972ccdbad7f5569096bd5794cd59271c6004a/src/rollup/getRollupConfig.ts#L15 https://github.com/Elderjs/elderjs/blob/162972ccdbad7f5569096bd5794cd59271c6004a/src/rollup/getRollupConfig.ts#L65-L77