From 040ba2bf5366c779de4001d9459ec471f920ff79 Mon Sep 17 00:00:00 2001 From: Dennis Czombera Date: Sat, 12 May 2018 15:19:33 +0200 Subject: [PATCH] Remove no longer needed #__PURE__ annotations for taggedTemplateLiteral helper (#7914) * Remove pure comment annotation * Update outputs --- .../interop-loose/imports-hoisting/output.js | 2 +- .../fixtures/interop/imports-hoisting/output.js | 2 +- .../src/index.js | 7 +------ .../fixtures/default/cache-revision/output.js | 4 ++-- .../test/fixtures/default/simple-tag/output.js | 4 ++-- .../test/fixtures/default/tag/output.js | 6 +++--- .../fixtures/default/template-revision/output.js | 16 ++++++++-------- .../test/fixtures/loose/tag/output.js | 6 +++--- .../fixtures/loose/template-revision/output.js | 16 ++++++++-------- 9 files changed, 29 insertions(+), 34 deletions(-) diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop-loose/imports-hoisting/output.js b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop-loose/imports-hoisting/output.js index df902a7c8f..d17f42975d 100644 --- a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop-loose/imports-hoisting/output.js +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop-loose/imports-hoisting/output.js @@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")); function _templateObject() { - const data = /*#__PURE__*/ (0, _taggedTemplateLiteral2.default)(["foo"]); + const data = (0, _taggedTemplateLiteral2.default)(["foo"]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop/imports-hoisting/output.js b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop/imports-hoisting/output.js index df902a7c8f..d17f42975d 100644 --- a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop/imports-hoisting/output.js +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/interop/imports-hoisting/output.js @@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")); function _templateObject() { - const data = /*#__PURE__*/ (0, _taggedTemplateLiteral2.default)(["foo"]); + const data = (0, _taggedTemplateLiteral2.default)(["foo"]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-template-literals/src/index.js b/packages/babel-plugin-transform-template-literals/src/index.js index 3373b02042..b595678374 100644 --- a/packages/babel-plugin-transform-template-literals/src/index.js +++ b/packages/babel-plugin-transform-template-literals/src/index.js @@ -1,5 +1,4 @@ import { declare } from "@babel/helper-plugin-utils"; -import annotateAsPure from "@babel/helper-annotate-as-pure"; import { template, types as t } from "@babel/core"; export default declare((api, options) => { @@ -83,13 +82,9 @@ export default declare((api, options) => { callExpressionInput.push(t.arrayExpression(raws)); } - const callExpression = t.callExpression(helperId, callExpressionInput); - annotateAsPure(callExpression); - callExpression._compact = true; - const lazyLoad = template.ast` function ${templateObject}() { - const data = ${callExpression}; + const data = ${t.callExpression(helperId, callExpressionInput)}; ${templateObject} = function() { return data }; return data; } diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/cache-revision/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/cache-revision/output.js index 7e41808f5f..1c2af18033 100644 --- a/packages/babel-plugin-transform-template-literals/test/fixtures/default/cache-revision/output.js +++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/cache-revision/output.js @@ -1,5 +1,5 @@ function _templateObject2() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["some template"]); + const data = _taggedTemplateLiteral(["some template"]); _templateObject2 = function () { return data; @@ -9,7 +9,7 @@ function _templateObject2() { } function _templateObject() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["some template"]); + const data = _taggedTemplateLiteral(["some template"]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/simple-tag/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/simple-tag/output.js index 87b40045d6..dd77aab5b4 100644 --- a/packages/babel-plugin-transform-template-literals/test/fixtures/default/simple-tag/output.js +++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/simple-tag/output.js @@ -1,5 +1,5 @@ function _templateObject2() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["first", "second"]); + const data = _taggedTemplateLiteral(["first", "second"]); _templateObject2 = function () { return data; @@ -9,7 +9,7 @@ function _templateObject2() { } function _templateObject() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["wow"]); + const data = _taggedTemplateLiteral(["wow"]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag/output.js index 6a37348dda..4e3651b5f3 100644 --- a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag/output.js +++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag/output.js @@ -1,5 +1,5 @@ function _templateObject3() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["wow\naB", " ", ""], ["wow\\naB", " ", ""]); + const data = _taggedTemplateLiteral(["wow\naB", " ", ""], ["wow\\naB", " ", ""]); _templateObject3 = function () { return data; @@ -9,7 +9,7 @@ function _templateObject3() { } function _templateObject2() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["wow\nab", " ", ""], ["wow\\nab", " ", ""]); + const data = _taggedTemplateLiteral(["wow\nab", " ", ""], ["wow\\nab", " ", ""]); _templateObject2 = function () { return data; @@ -19,7 +19,7 @@ function _templateObject2() { } function _templateObject() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["wow\na", "b ", ""], ["wow\\na", "b ", ""]); + const data = _taggedTemplateLiteral(["wow\na", "b ", ""], ["wow\\na", "b ", ""]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/template-revision/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/template-revision/output.js index 87294b20a3..372379c787 100644 --- a/packages/babel-plugin-transform-template-literals/test/fixtures/default/template-revision/output.js +++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/template-revision/output.js @@ -1,5 +1,5 @@ function _templateObject8() { - const data = /*#__PURE__*/ _taggedTemplateLiteral([void 0], ["\\01"]); + const data = _taggedTemplateLiteral([void 0], ["\\01"]); _templateObject8 = function () { return data; @@ -9,7 +9,7 @@ function _templateObject8() { } function _templateObject7() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u{-0}", "right"]); + const data = _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u{-0}", "right"]); _templateObject7 = function () { return data; @@ -19,7 +19,7 @@ function _templateObject7() { } function _templateObject6() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u000g", "right"]); + const data = _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u000g", "right"]); _templateObject6 = function () { return data; @@ -29,7 +29,7 @@ function _templateObject6() { } function _templateObject5() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\xg", "right"]); + const data = _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\xg", "right"]); _templateObject5 = function () { return data; @@ -39,7 +39,7 @@ function _templateObject5() { } function _templateObject4() { - const data = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0], ["left", "\\xg"]); + const data = _taggedTemplateLiteral(["left", void 0], ["left", "\\xg"]); _templateObject4 = function () { return data; @@ -49,7 +49,7 @@ function _templateObject4() { } function _templateObject3() { - const data = /*#__PURE__*/ _taggedTemplateLiteral([void 0, "right"], ["\\xg", "right"]); + const data = _taggedTemplateLiteral([void 0, "right"], ["\\xg", "right"]); _templateObject3 = function () { return data; @@ -59,7 +59,7 @@ function _templateObject3() { } function _templateObject2() { - const data = /*#__PURE__*/ _taggedTemplateLiteral([void 0], ["\\01"]); + const data = _taggedTemplateLiteral([void 0], ["\\01"]); _templateObject2 = function () { return data; @@ -69,7 +69,7 @@ function _templateObject2() { } function _templateObject() { - const data = /*#__PURE__*/ _taggedTemplateLiteral([void 0], ["\\unicode and \\u{55}"]); + const data = _taggedTemplateLiteral([void 0], ["\\unicode and \\u{55}"]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/loose/tag/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/loose/tag/output.js index 6091fa15aa..f403521d97 100644 --- a/packages/babel-plugin-transform-template-literals/test/fixtures/loose/tag/output.js +++ b/packages/babel-plugin-transform-template-literals/test/fixtures/loose/tag/output.js @@ -1,5 +1,5 @@ function _templateObject3() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["wow\naB", " ", ""], ["wow\\naB", " ", ""]); + const data = _taggedTemplateLiteralLoose(["wow\naB", " ", ""], ["wow\\naB", " ", ""]); _templateObject3 = function () { return data; @@ -9,7 +9,7 @@ function _templateObject3() { } function _templateObject2() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["wow\nab", " ", ""], ["wow\\nab", " ", ""]); + const data = _taggedTemplateLiteralLoose(["wow\nab", " ", ""], ["wow\\nab", " ", ""]); _templateObject2 = function () { return data; @@ -19,7 +19,7 @@ function _templateObject2() { } function _templateObject() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["wow\na", "b ", ""], ["wow\\na", "b ", ""]); + const data = _taggedTemplateLiteralLoose(["wow\na", "b ", ""], ["wow\\na", "b ", ""]); _templateObject = function () { return data; diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/loose/template-revision/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/loose/template-revision/output.js index bab93d9679..7aa707ca75 100644 --- a/packages/babel-plugin-transform-template-literals/test/fixtures/loose/template-revision/output.js +++ b/packages/babel-plugin-transform-template-literals/test/fixtures/loose/template-revision/output.js @@ -1,5 +1,5 @@ function _templateObject8() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose([void 0], ["\\01"]); + const data = _taggedTemplateLiteralLoose([void 0], ["\\01"]); _templateObject8 = function () { return data; @@ -9,7 +9,7 @@ function _templateObject8() { } function _templateObject7() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u{-0}", "right"]); + const data = _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u{-0}", "right"]); _templateObject7 = function () { return data; @@ -19,7 +19,7 @@ function _templateObject7() { } function _templateObject6() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u000g", "right"]); + const data = _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u000g", "right"]); _templateObject6 = function () { return data; @@ -29,7 +29,7 @@ function _templateObject6() { } function _templateObject5() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\xg", "right"]); + const data = _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\xg", "right"]); _templateObject5 = function () { return data; @@ -39,7 +39,7 @@ function _templateObject5() { } function _templateObject4() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0], ["left", "\\xg"]); + const data = _taggedTemplateLiteralLoose(["left", void 0], ["left", "\\xg"]); _templateObject4 = function () { return data; @@ -49,7 +49,7 @@ function _templateObject4() { } function _templateObject3() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose([void 0, "right"], ["\\xg", "right"]); + const data = _taggedTemplateLiteralLoose([void 0, "right"], ["\\xg", "right"]); _templateObject3 = function () { return data; @@ -59,7 +59,7 @@ function _templateObject3() { } function _templateObject2() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose([void 0], ["\\01"]); + const data = _taggedTemplateLiteralLoose([void 0], ["\\01"]); _templateObject2 = function () { return data; @@ -69,7 +69,7 @@ function _templateObject2() { } function _templateObject() { - const data = /*#__PURE__*/ _taggedTemplateLiteralLoose([void 0], ["\\unicode and \\u{55}"]); + const data = _taggedTemplateLiteralLoose([void 0], ["\\unicode and \\u{55}"]); _templateObject = function () { return data;