From ab98c724f74529d672f6c231c07151690cf43747 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Tue, 6 Dec 2016 18:38:04 -0500 Subject: [PATCH] remove comments by default in babel-preset-babili (#325) * remove comments by default in babel-preset-babili * tests --- .../__tests__/preset-tests.js | 22 +++++++++++++++++++ packages/babel-preset-babili/src/index.js | 1 + 2 files changed, 23 insertions(+) diff --git a/packages/babel-preset-babili/__tests__/preset-tests.js b/packages/babel-preset-babili/__tests__/preset-tests.js index c1ed19936..2a23f6700 100644 --- a/packages/babel-preset-babili/__tests__/preset-tests.js +++ b/packages/babel-preset-babili/__tests__/preset-tests.js @@ -39,4 +39,26 @@ describe("preset", () => { `); expect(transform(source)).toBe(expected); }); + + it("should fix remove comments", () => { + const source = unpad(` + var asdf = 1; // test + `); + const expected = unpad(` + var asdf = 1; + `); + expect(transform(source)).toBe(expected); + }); + + it("should keep license/preserve annotated comments", () => { + const source = unpad(` + /* @license */ + var asdf = 1; + `); + const expected = unpad(` + /* @license */ + var asdf = 1; + `); + expect(transform(source)).toBe(expected); + }); }); diff --git a/packages/babel-preset-babili/src/index.js b/packages/babel-preset-babili/src/index.js index d9aef47d8..1c5403f7d 100644 --- a/packages/babel-preset-babili/src/index.js +++ b/packages/babel-preset-babili/src/index.js @@ -107,6 +107,7 @@ function preset(context, _opts = {}) { return { minified: true, + comments: false, presets: [ { plugins } ],