forked from daren.hsu/line_push
update
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Babel
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+6
-3
@@ -1,5 +1,8 @@
|
||||
# `@babel/preset-modules`
|
||||
|
||||
> ℹ️ Starting from `@babel/preset-env` 7.9.0, you can enable the [`bugfixes: true` option](https://babeljs.io/docs/en/babel-preset-env#bugfixes) to get the same behavior as using `@babel/preset-modules`, but with support for custom `targets`.
|
||||
> If you need to target browsers with native modules support (like this preset does), you can use `targets: { esmodules: true }`.
|
||||
|
||||
A Babel preset that enables async/await, Tagged Templates, arrow functions, destructured and rest parameters, and more **in all modern browsers** ([88% of traffic](https://caniuse.com/#feat=es6-module)).
|
||||
|
||||
It works around bugs and inconsistencies in modern JavaScript engines by converting broken syntax to the _closest non-broken modern syntax_. Use this in place of `@babel/preset-env`'s [target.esmodules](https://babeljs.io/docs/en/babel-preset-env#targetsesmodules) option for smaller bundle size and improved performance.
|
||||
@@ -136,7 +139,7 @@ With [Terser's Node API](https://github.com/terser/terser#minify-options):
|
||||
|
||||
```js
|
||||
terser.minify({
|
||||
ecma: 8,
|
||||
ecma: 2017,
|
||||
safari10: true
|
||||
})
|
||||
```
|
||||
@@ -144,7 +147,7 @@ terser.minify({
|
||||
With [Terser CLI](https://npm.im/terser):
|
||||
|
||||
```sh
|
||||
terser --ecma 8 --safari10 ...
|
||||
terser --ecma 2017 --safari10 ...
|
||||
```
|
||||
|
||||
With [terser-webpack-plugin](https://webpack.js.org/plugins/terser-webpack-plugin/):
|
||||
@@ -155,7 +158,7 @@ module.exports = {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
ecma: 8,
|
||||
ecma: 2017,
|
||||
safari10: true
|
||||
}
|
||||
})
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -26,7 +26,7 @@ var _default = ({
|
||||
const id = t.cloneNode(path.parent.id);
|
||||
const binding = path.scope.getBinding(id.name); // if the binding gets reassigned anywhere, rename it
|
||||
|
||||
if (binding.constantViolations.length) {
|
||||
if (binding == null ? void 0 : binding.constantViolations.length) {
|
||||
path.scope.rename(id.name);
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+4
-4
@@ -31,7 +31,7 @@ var _default = ({
|
||||
let processed = state.get("processed");
|
||||
|
||||
if (!processed) {
|
||||
processed = new Map();
|
||||
processed = new WeakSet();
|
||||
state.set("processed", processed);
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ var _default = ({
|
||||
// identity`a${0}`
|
||||
|
||||
|
||||
const template = t.taggedTemplateExpression(identity, t.templateLiteral(path.node.quasi.quasis, expressions.map(() => t.numericLiteral(0))));
|
||||
processed.set(template, true); // Install an inline cache at the callsite using the global variable:
|
||||
const template = t.taggedTemplateExpression(t.cloneNode(identity), t.templateLiteral(path.node.quasi.quasis, expressions.map(() => t.numericLiteral(0))));
|
||||
processed.add(template); // Install an inline cache at the callsite using the global variable:
|
||||
// _t || (_t = identity`a${0}`)
|
||||
|
||||
const ident = path.scope.getProgramParent().generateDeclaredUidIdentifier("t");
|
||||
path.scope.getBinding(ident.name).path.parent.kind = "let";
|
||||
const inlineCache = t.logicalExpression("||", ident, t.assignmentExpression("=", ident, template)); // The original tag function becomes a plain function call.
|
||||
const inlineCache = t.logicalExpression("||", ident, t.assignmentExpression("=", t.cloneNode(ident), template)); // The original tag function becomes a plain function call.
|
||||
// The expressions omitted from the cached Strings tag are directly applied as arguments.
|
||||
// tag(_t || (_t = Object`a${0}`), 'hello')
|
||||
|
||||
|
||||
+22
-14
@@ -1,36 +1,39 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/preset-modules@0.1.3",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"@babel/preset-modules@0.1.5",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/preset-modules@0.1.3",
|
||||
"_id": "@babel/preset-modules@0.1.3",
|
||||
"_from": "@babel/preset-modules@0.1.5",
|
||||
"_id": "@babel/preset-modules@0.1.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Ra3JXOHBq2xd56xSF7lMKXdjBn3T772Y1Wet3yWnkDly9zHvJki029tAFzvAAK5cf4YV3yoxuP61crYRol6SVg==",
|
||||
"_integrity": "sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==",
|
||||
"_location": "/@babel/preset-modules",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/preset-modules@0.1.3",
|
||||
"raw": "@babel/preset-modules@0.1.5",
|
||||
"name": "@babel/preset-modules",
|
||||
"escapedName": "@babel%2fpreset-modules",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "0.1.3",
|
||||
"rawSpec": "0.1.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.1.3"
|
||||
"fetchSpec": "0.1.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/preset-env"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.3.tgz",
|
||||
"_spec": "0.1.3",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz",
|
||||
"_spec": "0.1.5",
|
||||
"_where": "/home/node/nuxt",
|
||||
"authors": [
|
||||
"Jason Miller <jason@developit.ca>"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/preset-modules/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/plugin-proposal-unicode-property-regex": "^7.4.4",
|
||||
@@ -43,10 +46,10 @@
|
||||
"@babel/cli": "^7.7.0",
|
||||
"@babel/core": "^7.7.2",
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"@babel/helper-plugin-test-runner": "^7.1.0",
|
||||
"@babel/helper-plugin-test-runner": "^7.14.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
|
||||
"@babel/plugin-transform-react-jsx": "^7.7.0",
|
||||
"@babel/preset-env": "^7.4.5",
|
||||
"@babel/preset-env": "^7.9.6",
|
||||
"acorn-jsx": "^5.0.1",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"babel-plugin-add-module-exports": "^1.0.2",
|
||||
@@ -84,6 +87,7 @@
|
||||
"src",
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/babel/preset-modules#readme",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
@@ -116,6 +120,10 @@
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/babel/preset-modules.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d lib --ignore '**/*.test.js'",
|
||||
"start": "concurrently -r 'npm:watch:* -s'",
|
||||
@@ -127,5 +135,5 @@
|
||||
"watch:build": "npm run -s build -- -w",
|
||||
"watch:test": "jest --watch"
|
||||
},
|
||||
"version": "0.1.3"
|
||||
"version": "0.1.5"
|
||||
}
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -20,7 +20,7 @@ export default ({ types: t }) => ({
|
||||
const id = t.cloneNode(path.parent.id);
|
||||
const binding = path.scope.getBinding(id.name);
|
||||
// if the binding gets reassigned anywhere, rename it
|
||||
if (binding.constantViolations.length) {
|
||||
if (binding?.constantViolations.length) {
|
||||
path.scope.rename(id.name);
|
||||
}
|
||||
path.node.id = id;
|
||||
|
||||
Generated
Vendored
+4
-4
@@ -23,7 +23,7 @@ export default ({ types: t }) => ({
|
||||
// tagged templates we've already dealt with
|
||||
let processed = state.get("processed");
|
||||
if (!processed) {
|
||||
processed = new Map();
|
||||
processed = new WeakSet();
|
||||
state.set("processed", processed);
|
||||
}
|
||||
|
||||
@@ -55,13 +55,13 @@ export default ({ types: t }) => ({
|
||||
// We replace all expressions with `0` ensure Strings has the same shape.
|
||||
// identity`a${0}`
|
||||
const template = t.taggedTemplateExpression(
|
||||
identity,
|
||||
t.cloneNode(identity),
|
||||
t.templateLiteral(
|
||||
path.node.quasi.quasis,
|
||||
expressions.map(() => t.numericLiteral(0))
|
||||
)
|
||||
);
|
||||
processed.set(template, true);
|
||||
processed.add(template);
|
||||
|
||||
// Install an inline cache at the callsite using the global variable:
|
||||
// _t || (_t = identity`a${0}`)
|
||||
@@ -72,7 +72,7 @@ export default ({ types: t }) => ({
|
||||
const inlineCache = t.logicalExpression(
|
||||
"||",
|
||||
ident,
|
||||
t.assignmentExpression("=", ident, template)
|
||||
t.assignmentExpression("=", t.cloneNode(ident), template)
|
||||
);
|
||||
|
||||
// The original tag function becomes a plain function call.
|
||||
|
||||
Reference in New Issue
Block a user