From c53844b3d467dedaadfb1077bb701f9c32557ba5 Mon Sep 17 00:00:00 2001 From: Brian Mulhall Date: Sat, 4 Apr 2020 13:42:42 -0500 Subject: [PATCH] bug fixes that came up during testing --- packages/minifier-js/minifier-tests.js | 23 ++++++----------------- packages/minifier-js/minifier.js | 4 ++-- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/packages/minifier-js/minifier-tests.js b/packages/minifier-js/minifier-tests.js index 6f19266fd1..6251b5c85d 100644 --- a/packages/minifier-js/minifier-tests.js +++ b/packages/minifier-js/minifier-tests.js @@ -1,25 +1,14 @@ -// this test case verifies that terser can minify code we give it Tinytest.add('minifier-js - verify simple JS minifications work', (test) => { - let terserResult = meteorJsMinify('function add(first,second){return first + second; }\n'); - test.equal(terserResult.code, 'function add(n,d){return n+d}'); - test.equal(terserResult.minifier, 'terser'); - + test.equal(terserResult.code, 'function add(n,d){return n+d}'); }); - -// this test case verifies that when terser can't handle something, babel-minify will step in as a fallback -Tinytest.add('minifier-js - syntax terser cannot handle is handled correctly by babel-minify', (test) => { - - let babelResult = meteorJsMinify('let number = 1_000_000_000_000;\n'); - test.equal(babelResult.code, 'let number=1e12;'); - test.equal(babelResult.minifier, 'babel-minify'); - +// this feature has been reqested in this issue https://github.com/terser/terser/issues/632 +// so when we bump the version and this fails we will know when :) +Tinytest.add('minifier-js - numeric seperator test', (test) => { + test.throws(() => meteorJsMinify('let number = 1_000_000_000_000;\n') ); }); -// This test case verifies the behavior when both terser and babel-minfiy fail -Tinytest.add('minifier-js - errors are handled correctly', (test) => { - +Tinytest.add('minifier-js - verify error handling is done correctly', (test) => { test.throws(() => meteorJsMinify('let name = {;\n')); - }); diff --git a/packages/minifier-js/minifier.js b/packages/minifier-js/minifier.js index 4ae1fcb692..f71c2b5223 100644 --- a/packages/minifier-js/minifier.js +++ b/packages/minifier-js/minifier.js @@ -1,6 +1,6 @@ const terser = Npm.require("terser"); -meteorJsMinify = function (source) { +meteorJsMinify = function (source) { const NODE_ENV = process.env.NODE_ENV || "development"; const terserOptions = { @@ -23,5 +23,5 @@ meteorJsMinify = function (source) { // the terser api doesnt throw exceptions, so we throw one ourselves if (terserResult.error) throw terserResult.error; - return terserResult.code; + return terserResult; };