diff --git a/packages/babel-plugin-minify-constant-folding/__tests__/constant-folding-test.js b/packages/babel-plugin-minify-constant-folding/__tests__/constant-folding-test.js index c074df7e5..7b0eb37ec 100644 --- a/packages/babel-plugin-minify-constant-folding/__tests__/constant-folding-test.js +++ b/packages/babel-plugin-minify-constant-folding/__tests__/constant-folding-test.js @@ -71,7 +71,7 @@ describe("constant-folding-plugin", () => { expect(transform(source)).toBe(source); }); - it("should handle script escape", () => { + xit("should handle script escape", () => { const source = unpad( ` " { expect(transform(source)).toBe(expected); }); - it("should handle style escape", () => { + xit("should handle style escape", () => { const source = unpad( ` " { expect(transform(source)).toBe(expected); }); - it("should handle html comment escape", () => { + xit("should handle html comment escape", () => { const source = unpad( ` " { ); expect(transform(source)).toBe(expected); }); + + it("should fix #440", () => { + const source = unpad( + ` + var x = "'cool'" + "test"; + ` + ); + const expected = unpad( + ` + var x = "'cool'test"; + ` + ); + expect(transform(source)).toBe(expected); + }); }); diff --git a/packages/babel-plugin-minify-constant-folding/package.json b/packages/babel-plugin-minify-constant-folding/package.json index 0a4581985..f7e1d0328 100644 --- a/packages/babel-plugin-minify-constant-folding/package.json +++ b/packages/babel-plugin-minify-constant-folding/package.json @@ -12,8 +12,6 @@ "babel-plugin" ], "dependencies": { - "babel-helper-evaluate-path": "^0.0.3", - "jsesc": "^2.4.0" - }, - "devDependencies": {} + "babel-helper-evaluate-path": "^0.0.3" + } } diff --git a/packages/babel-plugin-minify-constant-folding/src/index.js b/packages/babel-plugin-minify-constant-folding/src/index.js index 76bf3f149..f9826e5c7 100644 --- a/packages/babel-plugin-minify-constant-folding/src/index.js +++ b/packages/babel-plugin-minify-constant-folding/src/index.js @@ -1,7 +1,6 @@ "use strict"; const evaluate = require("babel-helper-evaluate-path"); -const jsesc = require("jsesc"); module.exports = ({ types: t, traverse }) => { const seen = Symbol("seen"); @@ -121,13 +120,6 @@ module.exports = ({ types: t, traverse }) => { } } - // https://github.com/babel/babili/issues/382 - if (typeof res.value === "string") { - res.value = jsesc(res.value, { - isScriptContext: true - }); - } - const node = t.valueToNode(res.value); node[seen] = true; path.replaceWith(node);