Skip to content

Instantly share code, notes, and snippets.

@gribnoysup
Created August 19, 2018 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gribnoysup/c053aadae16aff54decaf8e4a9b96e68 to your computer and use it in GitHub Desktop.
Save gribnoysup/c053aadae16aff54decaf8e4a9b96e68 to your computer and use it in GitHub Desktop.
/**
* All credit goes to Rich Harris
* https://github.com/Rich-Harris/yootils/blob/master/scripts/check-treeshaking.js
*/
const { rollup } = require('rollup');
async function check() {
const bundle = await rollup({
input: 'scripts/check-treeshaking-entry.js',
onwarn: (warning, handle) => {
if (warning.code !== 'EMPTY_BUNDLE') handle(warning);
}
});
const output = await bundle.generate({
format: 'esm'
});
if (output.code.trim() !== '') {
throw new Error('Tree-shaking failed');
}
}
check();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment