From 741a591640643c4397163b8434b0cbbc85b4c572 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 27 May 2020 13:17:00 +0800 Subject: [PATCH 1/3] - Git: Add coverage to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e..ba2a97b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +coverage From 07535346c6ebb0012d7fb40f3e1be4be6fc4a5c5 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 27 May 2020 13:17:30 +0800 Subject: [PATCH 2/3] - Maintenance: Add `.editorconfig` for pre-setting proper indent in IDE --- .editorconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c6812c1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +; EditorConfig file: https://EditorConfig.org +; Install the "EditorConfig" plugin into your editor to use + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true From 8df556a636f5190faf08f4cf7a185bbf961b04ce Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 27 May 2020 13:17:59 +0800 Subject: [PATCH 3/3] - Add tests to expand coverage (`numWorkers` and empty `nameCache.vars`) --- test/test.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/test.js b/test/test.js index 9fb2a6c..835a84f 100644 --- a/test/test.js +++ b/test/test.js @@ -15,6 +15,40 @@ test("minify", async () => { expect(output.map).toBeFalsy(); }); +test("minify with `numWorkers` option", async () => { + const bundle = await rollup({ + input: "test/fixtures/unminified.js", + plugins: [terser({ + numWorkers: 2 + })], + }); + const result = await bundle.generate({ format: "cjs" }); + expect(result.output).toHaveLength(1); + const [output] = result.output; + expect(output.code).toEqual( + '"use strict";window.a=5,window.a<3&&console.log(4);\n' + ); + expect(output.map).toBeFalsy(); +}); + +test("minify with empty `nameCache.vars`", async () => { + const bundle = await rollup({ + input: "test/fixtures/unminified.js", + plugins: [terser({ + nameCache: { + vars: {} + } + })], + }); + const result = await bundle.generate({ format: "cjs" }); + expect(result.output).toHaveLength(1); + const [output] = result.output; + expect(output.code).toEqual( + '"use strict";window.a=5,window.a<3&&console.log(4);\n' + ); + expect(output.map).toBeFalsy(); +}); + test("minify via terser options", async () => { const bundle = await rollup({ input: "test/fixtures/empty.js",