Dennis Czombera 4260ffd7ec Lazy load tagged template literal strings (#7855)
* Lazy load tagged template literal strings

* Update snapshots to reflect lazy loading

* Use pure annotation and remove unnecessary parenthesized expression

* Update snapshots

* Optimize lazy loading by doing assignment within logical expression

* Update snapshots to reflect optimization

* Use re-define function pattern to avoid hitting function size deopts

* Update snapshots to reflect the usage of the redefining function pattern
2018-05-10 14:54:10 -04:00

38 lines
836 B
JavaScript

function _templateObject2() {
const data = /*#__PURE__*/ _taggedTemplateLiteral(["some template"]);
_templateObject2 = function () {
return data;
};
return data;
}
function _templateObject() {
const data = /*#__PURE__*/ _taggedTemplateLiteral(["some template"]);
_templateObject = function () {
return data;
};
return data;
}
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var tag = v => v;
function foo() {
return tag(_templateObject());
}
function bar() {
return tag(_templateObject2());
}
expect(foo()).toBe(foo());
expect(foo()).toEqual(["some template"]);
expect(bar()).toBe(bar());
expect(bar()).toEqual(["some template"]);
expect(bar()).not.toBe(foo());