diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/@babel/plugin-transform-template-literals | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-vuepress.tar.gz xmake-docs-vuepress.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/@babel/plugin-transform-template-literals')
3 files changed, 0 insertions, 252 deletions
diff --git a/node_modules/@babel/plugin-transform-template-literals/README.md b/node_modules/@babel/plugin-transform-template-literals/README.md deleted file mode 100644 index d22f3b92..00000000 --- a/node_modules/@babel/plugin-transform-template-literals/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# @babel/plugin-transform-template-literals - -> Compile ES2015 template literals to ES5 - -## Example - -**In** - -```javascript -`foo${bar}`; -``` - -**Out** - -```javascript -"foo".concat(bar); -``` - -## Installation - -```sh -npm install --save-dev @babel/plugin-transform-template-literals -``` - -## Usage - -### Via `.babelrc` (Recommended) - -**.babelrc** - -Without options: - -```json -{ - "plugins": ["@babel/plugin-transform-template-literals"] -} -``` - -With options: - -```json -{ - "plugins": [ - ["@babel/plugin-transform-template-literals", { - "loose": true - }] - ] -} -``` - -### Via CLI - -```sh -babel --plugins @babel/plugin-transform-template-literals script.js -``` - -### Via Node API - -```javascript -require("@babel/core").transform("code", { - plugins: ["@babel/plugin-transform-template-literals"] -}); -``` - -## Options - -### `loose` - -`boolean`, defaults to `false`. - -When `true`, tagged template literal objects aren't frozen. All template literal expressions and quasis are combined with the `+` operator instead of with `String.prototype.concat`. - -When `false` or not set, all template literal expressions and quasis are combined with `String.prototype.concat`. It will handle cases with `Symbol.toPrimitive` correctly and throw correctly if template literal expression is a `Symbol()`. See [babel/babel#5791](https://github.com/babel/babel/pull/5791). - -**In** - -```javascript -`foo${bar}`; -``` - -**Out** - -```javascript -"foo" + bar; -``` diff --git a/node_modules/@babel/plugin-transform-template-literals/lib/index.js b/node_modules/@babel/plugin-transform-template-literals/lib/index.js deleted file mode 100644 index 672aeaec..00000000 --- a/node_modules/@babel/plugin-transform-template-literals/lib/index.js +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; - -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function _helperPluginUtils() { - return data; - }; - - return data; -} - -function _core() { - const data = require("@babel/core"); - - _core = function _core() { - return data; - }; - - return data; -} - -var _default = (0, _helperPluginUtils().declare)((api, options) => { - api.assertVersion(7); - const loose = options.loose; - let helperName = "taggedTemplateLiteral"; - if (loose) helperName += "Loose"; - - function buildConcatCallExressions(items) { - let avail = true; - return items.reduce(function (left, right) { - let canBeInserted = _core().types.isLiteral(right); - - if (!canBeInserted && avail) { - canBeInserted = true; - avail = false; - } - - if (canBeInserted && _core().types.isCallExpression(left)) { - left.arguments.push(right); - return left; - } - - return _core().types.callExpression(_core().types.memberExpression(left, _core().types.identifier("concat")), [right]); - }); - } - - return { - visitor: { - TaggedTemplateExpression(path) { - const node = path.node; - const quasi = node.quasi; - const strings = []; - const raws = []; - let isStringsRawEqual = true; - var _arr = quasi.quasis; - - for (var _i = 0; _i < _arr.length; _i++) { - const elem = _arr[_i]; - const _elem$value = elem.value, - raw = _elem$value.raw, - cooked = _elem$value.cooked; - const value = cooked == null ? path.scope.buildUndefinedNode() : _core().types.stringLiteral(cooked); - strings.push(value); - raws.push(_core().types.stringLiteral(raw)); - - if (raw !== cooked) { - isStringsRawEqual = false; - } - } - - const scope = path.scope.getProgramParent(); - const templateObject = scope.generateUidIdentifier("templateObject"); - const helperId = this.addHelper(helperName); - const callExpressionInput = [_core().types.arrayExpression(strings)]; - - if (!isStringsRawEqual) { - callExpressionInput.push(_core().types.arrayExpression(raws)); - } - - const lazyLoad = _core().template.ast` - function ${templateObject}() { - const data = ${_core().types.callExpression(helperId, callExpressionInput)}; - ${templateObject} = function() { return data }; - return data; - } - `; - scope.path.unshiftContainer("body", lazyLoad); - path.replaceWith(_core().types.callExpression(node.tag, [_core().types.callExpression(_core().types.cloneNode(templateObject), []), ...quasi.expressions])); - }, - - TemplateLiteral(path) { - const nodes = []; - const expressions = path.get("expressions"); - let index = 0; - var _arr2 = path.node.quasis; - - for (var _i2 = 0; _i2 < _arr2.length; _i2++) { - const elem = _arr2[_i2]; - - if (elem.value.cooked) { - nodes.push(_core().types.stringLiteral(elem.value.cooked)); - } - - if (index < expressions.length) { - const expr = expressions[index++]; - const node = expr.node; - - if (!_core().types.isStringLiteral(node, { - value: "" - })) { - nodes.push(node); - } - } - } - - const considerSecondNode = !loose || !_core().types.isStringLiteral(nodes[1]); - - if (!_core().types.isStringLiteral(nodes[0]) && considerSecondNode) { - nodes.unshift(_core().types.stringLiteral("")); - } - - let root = nodes[0]; - - if (loose) { - for (let i = 1; i < nodes.length; i++) { - root = _core().types.binaryExpression("+", root, nodes[i]); - } - } else if (nodes.length > 1) { - root = buildConcatCallExressions(nodes); - } - - path.replaceWith(root); - } - - } - }; -}); - -exports.default = _default;
\ No newline at end of file diff --git a/node_modules/@babel/plugin-transform-template-literals/package.json b/node_modules/@babel/plugin-transform-template-literals/package.json deleted file mode 100644 index aa851d1e..00000000 --- a/node_modules/@babel/plugin-transform-template-literals/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@babel/plugin-transform-template-literals", - "version": "7.0.0-beta.47", - "description": "Compile ES2015 template literals to ES5", - "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-template-literals", - "license": "MIT", - "main": "lib/index.js", - "dependencies": { - "@babel/helper-annotate-as-pure": "7.0.0-beta.47", - "@babel/helper-plugin-utils": "7.0.0-beta.47" - }, - "keywords": [ - "babel-plugin" - ], - "peerDependencies": { - "@babel/core": "7.0.0-beta.47" - }, - "devDependencies": { - "@babel/core": "7.0.0-beta.47", - "@babel/helper-plugin-test-runner": "7.0.0-beta.47" - } -} |
