Skip to content

Commit

Permalink
fix: throw internal error in case of Terser error
Browse files Browse the repository at this point in the history
Improvement with better error handling was proposed in:
- #17

but a reproduction is needed to add a test case, see
- #19
  • Loading branch information
brodybits committed Jan 22, 2023
1 parent 001e074 commit 03f414a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@ export const sizeSnapshot = (options?: Options = {}): Plugin => {

const outputName = chunk.fileName;

// Improvement with better error handling was proposed in
// brodybits/rollup-plugin-size-snapshot#17
// but a reproduction is needed to add a test case, see
// https://github.com/brodybits/rollup-plugin-size-snapshot/issues/19
const minified = minify(source).code;
if (!minified) {
throw new Error(
"INTERNAL ERROR - terser error - see https://github.com/brodybits/rollup-plugin-size-snapshot/issues/19"
);
}

const treeshakeSize = (code) =>
Promise.all([treeshakeWithRollup(code), treeshakeWithWebpack(code)]);

Expand Down

0 comments on commit 03f414a

Please sign in to comment.