Created
August 19, 2018 21:07
-
-
Save gribnoysup/c053aadae16aff54decaf8e4a9b96e68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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