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 diff --git a/.gitignore b/.gitignore index 3c3629e..ba2a97b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +coverage 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",