Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21228abfde | ||
|
|
e417437355 | ||
|
|
0bb720401b | ||
|
|
d35f2ad92b | ||
|
|
57759cb1a1 | ||
|
|
9e95da4eaa | ||
|
|
911c2d0bf4 | ||
|
|
116ca22def | ||
|
|
52fb884550 | ||
|
|
5cb38995c0 | ||
|
|
3c8e15dbc1 | ||
|
|
c1499b13ac | ||
|
|
7bcd62cfee | ||
|
|
47da5cf75a | ||
|
|
72471aff63 | ||
|
|
b9340bc597 | ||
|
|
731182eee4 | ||
|
|
f4eec5ca79 | ||
|
|
b60adce4cb | ||
|
|
66c4bc8f64 | ||
|
|
d2dc28ed2b | ||
|
|
0514a9f903 | ||
|
|
d1d3c823cc | ||
|
|
9b005dedfd | ||
|
|
4fdb71151f | ||
|
|
f611bb016b | ||
|
|
4dff205dc1 | ||
|
|
72fd2d192c | ||
|
|
35815832b5 | ||
|
|
9c45b8faf7 | ||
|
|
ca2918ab13 | ||
|
|
d915f31bcb | ||
|
|
4ca35ef8b9 | ||
|
|
4b73818c87 | ||
|
|
d305419da6 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "babel",
|
||||
"plugins": ["local-rules", "prettier"],
|
||||
"plugins": ["prettier", "@babel/development"],
|
||||
"rules": {
|
||||
"prettier/prettier": "error"
|
||||
},
|
||||
@@ -12,8 +12,8 @@
|
||||
{
|
||||
"files": ["packages/*/src/**/*.js", "codemods/*/src/**/*.js"],
|
||||
"rules": {
|
||||
"local-rules/no-undefined-identifier": "error",
|
||||
"local-rules/no-deprecated-clone": "error"
|
||||
"@babel/development/no-undefined-identifier": "error",
|
||||
"@babel/development/no-deprecated-clone": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -31,7 +31,7 @@
|
||||
"files": ["packages/babel-plugin-*/src/index.js"],
|
||||
"excludedFiles": ["packages/babel-plugin-transform-regenerator/**/*.js"],
|
||||
"rules": {
|
||||
"local-rules/plugin-name": "error"
|
||||
"@babel/development/plugin-name": "error"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
13
.flowconfig
13
.flowconfig
@@ -1,11 +1,10 @@
|
||||
[ignore]
|
||||
.*/build/.*
|
||||
.*/packages/.*/lib
|
||||
.*/packages/.*/test
|
||||
.*/codemods/.*/lib
|
||||
.*/codemods/.*/test
|
||||
.*/node_modules/conventional-changelog-core/
|
||||
.*/node_modules/module-deps/
|
||||
<PROJECT_ROOT>/build/.*
|
||||
<PROJECT_ROOT>/packages/.*/lib
|
||||
<PROJECT_ROOT>/packages/.*/test
|
||||
<PROJECT_ROOT>/codemods/.*/lib
|
||||
<PROJECT_ROOT>/codemods/.*/test
|
||||
<PROJECT_ROOT>/node_modules/module-deps/
|
||||
|
||||
[include]
|
||||
packages/*/src
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
9
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: 🐛 Bug Report
|
||||
about: If something isn't working as expected 🤔.
|
||||
name: "\U0001F41B Bug Report"
|
||||
about: "If something isn't working as expected \U0001F914."
|
||||
title: ''
|
||||
labels: 'i: bug, i: needs triage'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
@@ -31,7 +34,7 @@ A clear and concise description of what you expected to happen (or code).
|
||||
- Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
|
||||
- Node/npm version: [e.g. Node 8/npm 5]
|
||||
- OS: [e.g. OSX 10.13.4, Windows 10]
|
||||
- Monorepo [e.g. yes/no/Lerna]
|
||||
- Monorepo: [e.g. yes/no/Lerna]
|
||||
- How you are using Babel: [e.g. `cli`, `register`, `loader`]
|
||||
|
||||
**Possible Solution**
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
7
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: 🚀 Feature Request
|
||||
about: I have a suggestion (and may want to implement it 🙂)!
|
||||
name: "\U0001F680 Feature Request"
|
||||
about: "I have a suggestion (and may want to implement it \U0001F642)!"
|
||||
title: ''
|
||||
labels: 'i: enhancement, i: needs triage'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
10
.github/ISSUE_TEMPLATE/Regression-v7.md
vendored
10
.github/ISSUE_TEMPLATE/Regression-v7.md
vendored
@@ -1,12 +1,16 @@
|
||||
---
|
||||
name: 💥 v7 Regression
|
||||
about: Report an unexpected behavior in v7 from v6 (Check the upgrade guide first ✌️)
|
||||
name: "\U0001F4A5 v7 Regression"
|
||||
about: Report an unexpected behavior in v7 from v6 (Check the upgrade guide first
|
||||
✌️)
|
||||
title: ''
|
||||
labels: 'i: bug, 7.x: regression, i: needs triage'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# v7 Regression
|
||||
|
||||
> First check out: https://new.babeljs.io/docs/en/next/v7-migration.html
|
||||
> First check out: https://babeljs.io/docs/en/v7-migration
|
||||
> Also a partial upgrade tool: https://github.com/babel/babel-upgrade
|
||||
|
||||
**Potential Commit/PR that introduced the regression**
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/Support_question.md
vendored
7
.github/ISSUE_TEMPLATE/Support_question.md
vendored
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: 🤗 Support Question
|
||||
about: If you have a question 💬, please check out our Slack or StackOverflow!
|
||||
name: "\U0001F917 Support Question"
|
||||
about: "If you have a question \U0001F4AC, please check out our Slack or StackOverflow!"
|
||||
title: ''
|
||||
labels: 'i: question, i: needs triage'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
8
.github/ISSUE_TEMPLATE/Support_us.md
vendored
8
.github/ISSUE_TEMPLATE/Support_us.md
vendored
@@ -1,6 +1,10 @@
|
||||
---
|
||||
name: 🤝 Support us on Babel
|
||||
about: If you would like to support our efforts in maintaining this community-driven project 🙌!
|
||||
name: "\U0001F91D Support us on Babel"
|
||||
about: "If you would like to support our efforts in maintaining this community-driven
|
||||
project \U0001F64C!"
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
16
.travis.yml
16
.travis.yml
@@ -1,6 +1,5 @@
|
||||
git:
|
||||
depth: 5
|
||||
sudo: false
|
||||
language: node_js
|
||||
cache:
|
||||
yarn: true
|
||||
@@ -20,17 +19,18 @@ before_install:
|
||||
|
||||
install:
|
||||
# the `make test-ci` script runs this command already
|
||||
- if [ "$JOB" != "test" ]; then yarn install; fi
|
||||
- if [ "$JOB" != "test" ] && [ "$JOB" != "lint" ]; then yarn install; fi
|
||||
- if [ "$JOB" = "lint" ]; then make bootstrap; fi
|
||||
|
||||
before_script:
|
||||
- 'if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi'
|
||||
- 'if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi'
|
||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi
|
||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi
|
||||
|
||||
script:
|
||||
- 'if [ "$JOB" = "test" ]; then make test-ci; fi'
|
||||
- 'if [ "$JOB" = "lint" ]; then make lint && make flow; fi'
|
||||
- 'if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi'
|
||||
- 'if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi'
|
||||
- if [ "$JOB" = "test" ]; then make test-ci; fi
|
||||
- if [ "$JOB" = "lint" ]; then make lint && make flow; fi
|
||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi
|
||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
158
CHANGELOG.md
158
CHANGELOG.md
@@ -15,6 +15,164 @@ See [CHANGELOG - v4](/.github/CHANGELOG-v4.md), [CHANGELOG - v5](/.github/CHANGE
|
||||
See [CHANGELOG - 6to5](/.github/CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0.0-beta.29 version changelog.
|
||||
|
||||
## v7.2.1 (2018-12-04)
|
||||
|
||||
This release fixes a regression introduced in v7.2.0 (https://github.com/babel/babel/issues/9120)
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-helper-create-class-features-plugin`
|
||||
* [#9121](https://github.com/babel/babel/pull/9121) Don't use isClassPrivateMethod because it isn't supported in <7.2.0. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
## v7.2.0 (2018-12-03)
|
||||
|
||||
You can read more about this release at https://babeljs.io/blog/2018/12/03/7.2.0.
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-parser`
|
||||
* [#8289](https://github.com/babel/babel/pull/8289) Implement Smart Pipeline proposal in @babel/parser. ([@mAAdhaTTah](https://github.com/mAAdhaTTah))
|
||||
* `babel-core`
|
||||
* [#8986](https://github.com/babel/babel/pull/8986) Export @babel/parser#tokTypes in @babel/core. ([@kaicataldo](https://github.com/kaicataldo))
|
||||
* `babel-node`
|
||||
* [#9078](https://github.com/babel/babel/pull/9078) Pass `rootMode` from `@babel/node`.. ([@wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg))
|
||||
* `babel-generator`, `babel-helpers`, `babel-plugin-class-features`, `babel-plugin-proposal-private-methods`, `babel-plugin-syntax-class-properties`, `babel-types`
|
||||
* [#8654](https://github.com/babel/babel/pull/8654) Private class methods stage 3. ([@tim-mc](https://github.com/tim-mc))
|
||||
* `babel-preset-env`
|
||||
* [#9048](https://github.com/babel/babel/pull/9048) Update mappings for node 10 in preset-env. ([@existentialism](https://github.com/existentialism))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#9114](https://github.com/babel/babel/pull/9114) Parse non-octals with leading zeros in non strict mode correctly. ([@danez](https://github.com/danez))
|
||||
* [#9074](https://github.com/babel/babel/pull/9074) Disallow await inside arrow functions. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#9069](https://github.com/babel/babel/pull/9069) [flow] Allow type casts in array patterns inside arrow parameters. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#9058](https://github.com/babel/babel/pull/9058) Fix compatibility between typescript and jsx plugins in interface declarations. ([@danez](https://github.com/danez))
|
||||
* [#9055](https://github.com/babel/babel/pull/9055) Fix bug with parsing TS generic async arrow function. ([@existentialism](https://github.com/existentialism))
|
||||
* [#9035](https://github.com/babel/babel/pull/9035) Fix parsing typescript function types with destructuring. ([@danez](https://github.com/danez))
|
||||
* `babel-helper-fixtures`, `babel-parser`
|
||||
* [#9113](https://github.com/babel/babel/pull/9113) Ignore empty fixture directories and fix fixtures in the parser. ([@danez](https://github.com/danez))
|
||||
* `babel-preset-env`
|
||||
* [#9091](https://github.com/babel/babel/pull/9091) Update mapping for regex unicode plugin in preset-env. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-plugin-transform-destructuring`
|
||||
* [#8916](https://github.com/babel/babel/pull/8916) Fix destructuring assignment in arrow functions without block. ([@RubenVerborgh](https://github.com/RubenVerborgh))
|
||||
* `babel-plugin-proposal-optional-chaining`
|
||||
* [#9073](https://github.com/babel/babel/pull/9073) Microbouji patch/8136. ([@jridgewell](https://github.com/jridgewell))
|
||||
* `babel-core`, `babel-helper-wrap-function`, `babel-plugin-proposal-async-generator-functions`, `babel-plugin-proposal-function-sent`, `babel-plugin-transform-async-to-generator`, `babel-plugin-transform-classes`
|
||||
* [#9039](https://github.com/babel/babel/pull/9039) Fix recursive async function expressions. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-core`
|
||||
* [#9034](https://github.com/babel/babel/pull/9034) Normalize presets before merging config with others.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-generator`
|
||||
* [#9089](https://github.com/babel/babel/pull/9089) Remove unused variable. ([@Gcaufy](https://github.com/Gcaufy))
|
||||
* `babel-node`
|
||||
* [#9079](https://github.com/babel/babel/pull/9079) Move `fs-readdir-recursive` and `output-file-sync` to `devDependencies` for `@babel/node`.. ([@wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg))
|
||||
* `babel-parser`
|
||||
* [#9046](https://github.com/babel/babel/pull/9046) a better error message for disallowed trailing commas/additional parameters after rest elements in function params. ([@morozRed](https://github.com/morozRed))
|
||||
* `babel-*`
|
||||
* [#8769](https://github.com/babel/babel/pull/8769) Add plugins name. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-class-properties`, `babel-plugin-proposal-private-methods`
|
||||
* [#9083](https://github.com/babel/babel/pull/9083) Make @babel/plugin-class-features a normal helper package. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* Other
|
||||
* [#9096](https://github.com/babel/babel/pull/9096) Add node 11 to CI and remove node 9. ([@danez](https://github.com/danez))
|
||||
* [#9094](https://github.com/babel/babel/pull/9094) Skip minifying standalone in non-publish runs. ([@danez](https://github.com/danez))
|
||||
* `babel-types`
|
||||
* [#9093](https://github.com/babel/babel/pull/9093) Fix warning when using prettier in code generators. ([@danez](https://github.com/danez))
|
||||
* `babel-generator`
|
||||
* [#9089](https://github.com/babel/babel/pull/9089) Remove unused variable. ([@Gcaufy](https://github.com/Gcaufy))
|
||||
|
||||
## v7.1.6 (2018-11-13)
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-generator`
|
||||
* [#9003](https://github.com/babel/babel/pull/9003) Fix retainLines regression for arrow functions. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-types`
|
||||
* [#8997](https://github.com/babel/babel/pull/8997) Fix cloneNode with typeAnnotation.. ([@neoziro](https://github.com/neoziro))
|
||||
* `babel-plugin-transform-flow-strip-types`, `babel-plugin-transform-react-jsx`
|
||||
* [#8701](https://github.com/babel/babel/pull/8701) Fix "TypeError: comments is not iterable". ([@AlicanC](https://github.com/AlicanC))
|
||||
* `babel-core`
|
||||
* [#9004](https://github.com/babel/babel/pull/9004) Fix browser files to have the same API as the nodejs ones. ([@danez](https://github.com/danez))
|
||||
* Other
|
||||
* [#9007](https://github.com/babel/babel/pull/9007) [Types] fix generated TS/Flow comment types. ([@ljqx](https://github.com/ljqx))
|
||||
* `babel-preset-env`
|
||||
* [#8555](https://github.com/babel/babel/pull/8555) preset-env: fix `opera` from `esmodules` target and Browserslist not used. ([@ylemkimon](https://github.com/ylemkimon))
|
||||
* `babel-plugin-proposal-decorators`, `babel-traverse`
|
||||
* [#8970](https://github.com/babel/babel/pull/8970) [decorators] Correctly insert `_initialize(this)` after `super()`.. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-parser`
|
||||
* [#8972](https://github.com/babel/babel/pull/8972) Fix several edge cases with context expression state. ([@danez](https://github.com/danez))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-parser`
|
||||
* [#8984](https://github.com/babel/babel/pull/8984) Rename primitive types to reserved types. ([@danez](https://github.com/danez))
|
||||
|
||||
#### :house: Internal
|
||||
* [#8982](https://github.com/babel/babel/pull/8982) fix publish command [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
* [#8988](https://github.com/babel/babel/pull/8988) Remove definition of micromatch which was removed.. ([@danez](https://github.com/danez))
|
||||
|
||||
## v7.1.5 (2018-11-06)
|
||||
|
||||
#### :eyeglasses: Spec Compliancy
|
||||
* `babel-parser`, `babylon`
|
||||
* [#7727](https://github.com/babel/babel/pull/7727) Fix await in function name and parameters. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-parser`
|
||||
* [#8828](https://github.com/babel/babel/pull/8828) Typescript: Validate tuple type element positions. ([@Retsam](https://github.com/Retsam))
|
||||
* [#8883](https://github.com/babel/babel/pull/8883) [flow] Add support for parsing `_` as implicit instantiation in call/new. ([@jbrown215](https://github.com/jbrown215))
|
||||
* `babel-core`, `babel-generator`, `babel-parser`, `babel-plugin-syntax-typescript`, `babel-traverse`
|
||||
* [#8448](https://github.com/babel/babel/pull/8448) Remove Babylon plugins for features already merged to the ECMAScript spec. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-parser`, `babel-types`
|
||||
* [#8884](https://github.com/babel/babel/pull/8884) [flow] Explicit inexact objects with `...`. ([@jbrown215](https://github.com/jbrown215))
|
||||
* `babel-preset-env`
|
||||
* [#8898](https://github.com/babel/babel/pull/8898) Update preset-env data. ([@existentialism](https://github.com/existentialism))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#8956](https://github.com/babel/babel/pull/8956) Do not allow TypeCastExpressions w/o parens . ([@danez](https://github.com/danez))
|
||||
* [#8954](https://github.com/babel/babel/pull/8954) Allow function types in type params within arrow return types. ([@danez](https://github.com/danez))
|
||||
* [#8866](https://github.com/babel/babel/pull/8866) Closes [#8865](https://github.com/babel/babel/issues/8865). ([@byronluk](https://github.com/byronluk))
|
||||
* `babel-core`
|
||||
* [#8910](https://github.com/babel/babel/pull/8910) Resolve babel.config.js 'babelrcRoots' values relative to the config file.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* [#8950](https://github.com/babel/babel/pull/8950) Fix message when plugin of a wrong type is passed. ([@everdimension](https://github.com/everdimension))
|
||||
* `babel-plugin-transform-block-scoping`
|
||||
* [#8937](https://github.com/babel/babel/pull/8937) rename colliding let bindings with for loop init. ([@byronluk](https://github.com/byronluk))
|
||||
* [#8914](https://github.com/babel/babel/pull/8914) Treat break inside block inside loop. ([@thiagoarrais](https://github.com/thiagoarrais))
|
||||
* `babel-preset-env`
|
||||
* [#8926](https://github.com/babel/babel/pull/8926) preset-env: Edge support for arrow param destructuring. ([@benmosher](https://github.com/benmosher))
|
||||
* `babel-generator`
|
||||
* [#8868](https://github.com/babel/babel/pull/8868) fix single-arg async arrows when retainLines=true. ([@ryanwmarsh](https://github.com/ryanwmarsh))
|
||||
* `babel-traverse`
|
||||
* [#8880](https://github.com/babel/babel/pull/8880) fix: Expression x === 'y' && '' should not evaluate to undefined.. ([@Cyp](https://github.com/Cyp))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* [#8873](https://github.com/babel/babel/pull/8873) fixed an extra word. ([@vvyomjjain](https://github.com/vvyomjjain))
|
||||
|
||||
## v7.1.4 (2018-10-11)
|
||||
|
||||
Just re-published `@babel/traverse` without `**` so that it works in Node 6.
|
||||
|
||||
## v7.1.3 (2018-10-11)
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-generator`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-types`
|
||||
* [#8720](https://github.com/babel/babel/pull/8720) Typescript - Tuple elements can be optional. ([@Retsam](https://github.com/Retsam))
|
||||
* `babel-traverse`
|
||||
* [#8833](https://github.com/babel/babel/pull/8833) Insertafter jsx fix. ([@kevintab95](https://github.com/kevintab95))
|
||||
* `babel-parser`
|
||||
* [#8830](https://github.com/babel/babel/pull/8830) Correct handling of newline after async with paren-less arrow func. ([@Retsam](https://github.com/Retsam))
|
||||
* [#8756](https://github.com/babel/babel/pull/8756) class private methods and properties: should not allow spaces between # and identifier. ([@macabeus](https://github.com/macabeus))
|
||||
* [#8804](https://github.com/babel/babel/pull/8804) Fix parsing of slash after class expression. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8767](https://github.com/babel/babel/pull/8767) [decorators] [typescript] Parse type parameters. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#8792](https://github.com/babel/babel/pull/8792) Fix perf issue in typescript parser plugin. ([@matthewrobertson](https://github.com/matthewrobertson))
|
||||
* `babel-generator`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-types`
|
||||
* [#8805](https://github.com/babel/babel/pull/8805) Typescript - Tuples can include rest elements. ([@Retsam](https://github.com/Retsam))
|
||||
* `babel-types`
|
||||
* [#8791](https://github.com/babel/babel/pull/8791) types: allow jsxEmptyExpression inside jsxExpressionContainer. ([@tvooo](https://github.com/tvooo))
|
||||
* `babel-plugin-transform-modules-systemjs`
|
||||
* [#8820](https://github.com/babel/babel/pull/8820) System module format - fixes function hoisting failure case. ([@guybedford](https://github.com/guybedford))
|
||||
* `babel-plugin-transform-destructuring`
|
||||
* [#8793](https://github.com/babel/babel/pull/8793) Ensure destructuring's computed key handling matches object-rest-spread. ([@existentialism](https://github.com/existentialism))
|
||||
|
||||
## 7.1.2 (2018-09-28)
|
||||
|
||||
Same as v7.1.1, except compiled against Node 6 instead of Node 8 by accident (e.g had `async functions`).
|
||||
|
||||
11
Makefile
11
Makefile
@@ -28,6 +28,12 @@ build-standalone:
|
||||
build-preset-env-standalone:
|
||||
./node_modules/.bin/gulp build-babel-preset-env-standalone
|
||||
|
||||
prepublish-build-standalone:
|
||||
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-standalone
|
||||
|
||||
prepublish-build-preset-env-standalone:
|
||||
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-preset-env-standalone
|
||||
|
||||
build-dist: build
|
||||
cd packages/babel-polyfill; \
|
||||
scripts/build-dist.sh
|
||||
@@ -115,7 +121,7 @@ prepublish-build:
|
||||
rm -rf packages/babel-runtime/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/core-js
|
||||
BABEL_ENV=production IS_PUBLISH=true make build-dist
|
||||
BABEL_ENV=production make build-dist
|
||||
make clone-license
|
||||
|
||||
prepublish:
|
||||
@@ -124,8 +130,7 @@ prepublish:
|
||||
make test
|
||||
|
||||
publish: prepublish
|
||||
# --only-explicit-updates
|
||||
./node_modules/.bin/lerna publish --force-publish="@babel/runtime,@babel/runtime-corejs2" --dangerously-only-publish-explicit-updates-this-is-a-custom-flag-for-babel-and-you-should-not-be-using-it-just-deal-with-more-packages-being-published-it-is-not-a-big-deal
|
||||
./node_modules/.bin/lerna publish --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/standalone,@babel/preset-env-standalone" --require-scripts
|
||||
make clean
|
||||
|
||||
bootstrap: clean-all
|
||||
|
||||
20
README.md
20
README.md
@@ -48,35 +48,15 @@ Become a sponsor and get your logo on our README on Github with a link to your s
|
||||
<a href="https://opencollective.com/babel/sponsor/12/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/13/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/14/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/15/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/16/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/17/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/18/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/19/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/20/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/21/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/22/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/23/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/24/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/25/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/26/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/27/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/28/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/babel/sponsor/29/website" target="_blank"><img src="https://opencollective.com/babel/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## Patreon Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://www.patreon.com/henryzhu)]
|
||||
|
||||
## Silver
|
||||
|
||||
<a href="https://issue.sh/?utm_medium=github&utm_campaign=babel" target="_blank"><img src="https://user-images.githubusercontent.com/5557143/43912065-c8cdff78-9c33-11e8-829a-0b4166ccc215.png"></a>
|
||||
|
||||
## Bronze
|
||||
|
||||
<a href="http://teamextension.io/" target="_blank"><img src="https://teamextension.io/dist/img/logo/te-logo-compact.png" height="64"></a>
|
||||
<a href="https://webflow.com/" target="_blank"><img src="https://opencollective.com/proxy/images/?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F4a5024b0-8cf2-11e7-b1a2-b30b1de1463c.png&height=64"></a>
|
||||
<p><a href="https://twitter.com/mikesherov">Mike Sherov</a></p>
|
||||
|
||||
## Intro
|
||||
|
||||
|
||||
15
lerna.json
15
lerna.json
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.2.1",
|
||||
"version": "7.2.4",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
@@ -14,21 +13,21 @@
|
||||
"PR: Internal :house:": ":house: Internal"
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"command": {
|
||||
"publish": {
|
||||
"ignore": [
|
||||
"ignoreChanges": [
|
||||
"*.md",
|
||||
"*.json",
|
||||
"*.txt",
|
||||
"test/**",
|
||||
"codemods/**",
|
||||
"package.json"
|
||||
"# We ignore every JSON file, except for built-in-modules, built-ins and plugins defined in babel-preset-env/data.",
|
||||
"@(!(built-in-modules|built-ins|plugins)).json"
|
||||
]
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*",
|
||||
"codemods/*"
|
||||
"codemods/*",
|
||||
"packages/*"
|
||||
],
|
||||
"npmClient": "yarn",
|
||||
"npmClientArgs": [
|
||||
|
||||
36
package.json
36
package.json
@@ -9,34 +9,34 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.1.5",
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/plugin-proposal-class-properties": "^7.1.0",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
|
||||
"@babel/plugin-transform-runtime": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.6",
|
||||
"@babel/cli": "^7.2.0",
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/eslint-plugin-development": "^1.0.1",
|
||||
"@babel/plugin-proposal-class-properties": "^7.2.1",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
|
||||
"@babel/plugin-transform-runtime": "^7.2.0",
|
||||
"@babel/preset-env": "^7.2.0",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"@babel/runtime": "^7.1.5",
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"babel-core": "^7.0.0-0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-jest": "^23.6.0",
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-transform-charcodes": "^0.1.0",
|
||||
"babel-plugin-transform-charcodes": "^0.1.1",
|
||||
"browserify": "^16.2.2",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"chalk": "^2.3.2",
|
||||
"charcodes": "^0.1.0",
|
||||
"charcodes": "^0.1.1",
|
||||
"derequire": "^2.0.2",
|
||||
"enhanced-resolve": "^3.0.0",
|
||||
"eslint": "^5.9.0",
|
||||
"eslint-config-babel": "^8.0.2",
|
||||
"eslint-plugin-flowtype": "^3.2.0",
|
||||
"eslint-plugin-local-rules": "0.1.0",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"flow-bin": "^0.82.0",
|
||||
"flow-bin": "^0.87.0",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-babel": "^8.0.0",
|
||||
@@ -49,7 +49,7 @@
|
||||
"gulp-watch": "^5.0.1",
|
||||
"husky": "^1.2.0",
|
||||
"jest": "^23.6.0",
|
||||
"lerna": "^2.11.0",
|
||||
"lerna": "^3.6.0",
|
||||
"lerna-changelog": "^0.5.0",
|
||||
"lint-staged": "^8.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
@@ -69,6 +69,9 @@
|
||||
"webpack-dependency-suite": "^2.4.4",
|
||||
"webpack-stream": "^4.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@lerna/**/@lerna/collect-updates": "https://github.com/nicolo-ribaudo/lerna.git#babel-collect-updates"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.9.0 < 12.0.0",
|
||||
"npm": ">= 3.x <= 6.x",
|
||||
@@ -124,6 +127,9 @@
|
||||
"/test/tmp/",
|
||||
"/test/__data__/",
|
||||
"<rootDir>/build/"
|
||||
]
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.3",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -22,7 +22,7 @@ commander.option(
|
||||
"comma-separated list of plugin names",
|
||||
collect,
|
||||
);
|
||||
commander.option("--config-file [path]", "Path a to .babelrc file to use");
|
||||
commander.option("--config-file [path]", "Path to a .babelrc file to use");
|
||||
commander.option(
|
||||
"--env-name [name]",
|
||||
"The name of the 'env' to use when loading configs and plugins. " +
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.2",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -34,12 +34,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.2.0",
|
||||
"@babel/generator": "^7.2.2",
|
||||
"@babel/helpers": "^7.2.0",
|
||||
"@babel/parser": "^7.2.0",
|
||||
"@babel/template": "^7.1.2",
|
||||
"@babel/traverse": "^7.1.6",
|
||||
"@babel/types": "^7.2.0",
|
||||
"@babel/parser": "^7.2.2",
|
||||
"@babel/template": "^7.2.2",
|
||||
"@babel/traverse": "^7.2.2",
|
||||
"@babel/types": "^7.2.2",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^4.1.0",
|
||||
"json5": "^2.1.0",
|
||||
|
||||
@@ -43,6 +43,7 @@ export function makeWeakCache<
|
||||
>(
|
||||
handler: (ArgT, CacheConfigurator<SideChannel>) => ResultT,
|
||||
): (ArgT, SideChannel) => ResultT {
|
||||
// $FlowIssue https://github.com/facebook/flow/issues/4528
|
||||
return makeCachedFunction(new WeakMap(), handler);
|
||||
}
|
||||
|
||||
@@ -54,6 +55,7 @@ function makeCachedFunction<
|
||||
ArgT,
|
||||
ResultT,
|
||||
SideChannel,
|
||||
// $FlowIssue https://github.com/facebook/flow/issues/4528
|
||||
Cache: CacheMap<ArgT, ResultT, SideChannel>,
|
||||
>(
|
||||
callCache: Cache,
|
||||
|
||||
@@ -350,7 +350,7 @@ function validateNested(loc: NestingPath, opts: {}) {
|
||||
NONPRESET_VALIDATORS[key] ||
|
||||
BABELRC_VALIDATORS[key] ||
|
||||
ROOT_VALIDATORS[key] ||
|
||||
throwUnknownError;
|
||||
(throwUnknownError: Validator<void>);
|
||||
|
||||
validator(optLoc, opts[key]);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.2",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,7 +14,7 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.2.0",
|
||||
"@babel/types": "^7.2.2",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.10",
|
||||
"source-map": "^0.5.0",
|
||||
@@ -22,6 +22,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.2.0",
|
||||
"@babel/parser": "^7.2.0"
|
||||
"@babel/parser": "^7.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,3 +151,15 @@ export function BigIntLiteral(node: Object) {
|
||||
}
|
||||
this.token(node.value);
|
||||
}
|
||||
|
||||
export function PipelineTopicExpression(node: Object) {
|
||||
this.print(node.expression, node);
|
||||
}
|
||||
|
||||
export function PipelineBareFunction(node: Object) {
|
||||
this.print(node.callee, node);
|
||||
}
|
||||
|
||||
export function PipelinePrimaryTopicReference() {
|
||||
this.token("#");
|
||||
}
|
||||
|
||||
1
packages/babel-generator/test/fixtures/types/PipelineBareFunction/input.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/types/PipelineBareFunction/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let result = "hello" |> doubleSay |> text.capitalize |> a.b.exclaim;
|
||||
3
packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"]
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/types/PipelineBareFunction/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/types/PipelineBareFunction/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let result = "hello" |> doubleSay |> text.capitalize |> a.b.exclaim;
|
||||
8
packages/babel-generator/test/fixtures/types/PipelineTopicExpression/input.js
vendored
Normal file
8
packages/babel-generator/test/fixtures/types/PipelineTopicExpression/input.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
value |> # + 1;
|
||||
value |> 1 + #;
|
||||
value |> do {
|
||||
#;
|
||||
};
|
||||
value |> do {
|
||||
if (yes) #;
|
||||
};
|
||||
3
packages/babel-generator/test/fixtures/types/PipelineTopicExpression/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/types/PipelineTopicExpression/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"]
|
||||
}
|
||||
8
packages/babel-generator/test/fixtures/types/PipelineTopicExpression/output.js
vendored
Normal file
8
packages/babel-generator/test/fixtures/types/PipelineTopicExpression/output.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
value |> # + 1;
|
||||
value |> 1 + #;
|
||||
value |> do {
|
||||
#;
|
||||
};
|
||||
value |> do {
|
||||
if (yes) #;
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@babel/helper-create-class-features-plugin",
|
||||
"version": "7.2.1",
|
||||
"version": "7.2.3",
|
||||
"author": "The Babel Team (https://babeljs.io/team)",
|
||||
"license": "MIT",
|
||||
"description": "Compile class public and private fields, private methods and decorators to ES6",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-class-features",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-create-class-features-plugin",
|
||||
"main": "lib/index.js",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -18,13 +18,13 @@
|
||||
"@babel/helper-member-expression-to-functions": "^7.0.0",
|
||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/helper-replace-supers": "^7.1.0"
|
||||
"@babel/helper-replace-supers": "^7.2.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,154 @@
|
||||
export function hasDecorators(path) {
|
||||
return !!(path.node.decorators && path.node.decorators.length);
|
||||
import { types as t, template } from "@babel/core";
|
||||
import ReplaceSupers from "@babel/helper-replace-supers";
|
||||
|
||||
export function hasOwnDecorators(node) {
|
||||
return !!(node.decorators && node.decorators.length);
|
||||
}
|
||||
|
||||
export function hasDecorators(node) {
|
||||
return hasOwnDecorators(node) || node.body.body.some(hasOwnDecorators);
|
||||
}
|
||||
|
||||
function prop(key, value) {
|
||||
if (!value) return null;
|
||||
return t.objectProperty(t.identifier(key), value);
|
||||
}
|
||||
|
||||
function value(body, params = [], async, generator) {
|
||||
const method = t.objectMethod("method", t.identifier("value"), params, body);
|
||||
method.async = !!async;
|
||||
method.generator = !!generator;
|
||||
return method;
|
||||
}
|
||||
|
||||
function takeDecorators(node) {
|
||||
let result;
|
||||
if (node.decorators && node.decorators.length > 0) {
|
||||
result = t.arrayExpression(
|
||||
node.decorators.map(decorator => decorator.expression),
|
||||
);
|
||||
}
|
||||
node.decorators = undefined;
|
||||
return result;
|
||||
}
|
||||
|
||||
function getKey(node) {
|
||||
if (node.computed) {
|
||||
return node.key;
|
||||
} else if (t.isIdentifier(node.key)) {
|
||||
return t.stringLiteral(node.key.name);
|
||||
} else {
|
||||
return t.stringLiteral(String(node.key.value));
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: This function can be easily bound as .bind(file, classRef, superRef)
|
||||
// to make it easier to use it in a loop.
|
||||
function extractElementDescriptor(/* this: File, */ classRef, superRef, path) {
|
||||
const { node, scope } = path;
|
||||
const isMethod = path.isClassMethod();
|
||||
|
||||
if (path.isPrivate()) {
|
||||
throw path.buildCodeFrameError(
|
||||
`Private ${
|
||||
isMethod ? "methods" : "fields"
|
||||
} in decorated classes are not supported yet.`,
|
||||
);
|
||||
}
|
||||
|
||||
new ReplaceSupers(
|
||||
{
|
||||
methodPath: path,
|
||||
methodNode: node,
|
||||
objectRef: classRef,
|
||||
isStatic: node.static,
|
||||
superRef,
|
||||
scope,
|
||||
file: this,
|
||||
},
|
||||
true,
|
||||
).replace();
|
||||
|
||||
const properties = [
|
||||
prop("kind", t.stringLiteral(isMethod ? node.kind : "field")),
|
||||
prop("decorators", takeDecorators(node)),
|
||||
prop("static", node.static && t.booleanLiteral(true)),
|
||||
prop("key", getKey(node)),
|
||||
isMethod
|
||||
? value(node.body, node.params, node.async, node.generator)
|
||||
: node.value
|
||||
? value(template.ast`{ return ${node.value} }`)
|
||||
: prop("value", scope.buildUndefinedNode()),
|
||||
].filter(Boolean);
|
||||
|
||||
path.remove();
|
||||
|
||||
return t.objectExpression(properties);
|
||||
}
|
||||
|
||||
function addDecorateHelper(file) {
|
||||
try {
|
||||
return file.addHelper("decorate");
|
||||
} catch (err) {
|
||||
if (err.code === "BABEL_HELPER_UNKNOWN") {
|
||||
err.message +=
|
||||
"\n '@babel/plugin-transform-decorators' in non-legacy mode" +
|
||||
" requires '@babel/core' version ^7.0.2 and you appear to be using" +
|
||||
" an older version.";
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
export function buildDecoratedClass(ref, path, elements, file) {
|
||||
const { node, scope } = path;
|
||||
const initializeId = scope.generateUidIdentifier("initialize");
|
||||
const isDeclaration = node.id && path.isDeclaration();
|
||||
const isStrict = path.isInStrictMode();
|
||||
const { superClass } = node;
|
||||
|
||||
node.type = "ClassDeclaration";
|
||||
if (!node.id) node.id = t.cloneNode(ref);
|
||||
|
||||
let superId;
|
||||
if (superClass) {
|
||||
superId = scope.generateUidIdentifierBasedOnNode(node.superClass, "super");
|
||||
node.superClass = superId;
|
||||
}
|
||||
|
||||
const classDecorators = takeDecorators(node);
|
||||
const definitions = t.arrayExpression(
|
||||
elements.map(extractElementDescriptor.bind(file, node.id, superId)),
|
||||
);
|
||||
|
||||
let replacement = template.expression.ast`
|
||||
${addDecorateHelper(file)}(
|
||||
${classDecorators || t.nullLiteral()},
|
||||
function (${initializeId}, ${superClass ? superId : null}) {
|
||||
${node}
|
||||
return { F: ${t.cloneNode(node.id)}, d: ${definitions} };
|
||||
},
|
||||
${superClass}
|
||||
)
|
||||
`;
|
||||
let classPathDesc = "arguments.1.body.body.0";
|
||||
|
||||
if (!isStrict) {
|
||||
replacement.arguments[1].body.directives.push(
|
||||
t.directive(t.directiveLiteral("use strict")),
|
||||
);
|
||||
}
|
||||
|
||||
if (isDeclaration) {
|
||||
replacement = template.ast`let ${ref} = ${replacement}`;
|
||||
classPathDesc = "declarations.0.init." + classPathDesc;
|
||||
}
|
||||
|
||||
return {
|
||||
instanceNodes: [template.statement.ast`${initializeId}(this)`],
|
||||
wrapClass(path) {
|
||||
path.replaceWith(replacement);
|
||||
return path.get(classPathDesc);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { hasDecorators } from "./decorators";
|
||||
import { hasOwnDecorators } from "./decorators";
|
||||
|
||||
export const FEATURES = Object.freeze({
|
||||
//classes: 1 << 0,
|
||||
@@ -39,14 +39,18 @@ export function isLoose(file, feature) {
|
||||
}
|
||||
|
||||
export function verifyUsedFeatures(path, file) {
|
||||
if (hasDecorators(path) && !hasFeature(file, FEATURES.decorators)) {
|
||||
throw path.buildCodeFrameError("Decorators are not enabled.");
|
||||
}
|
||||
if (hasOwnDecorators(path)) {
|
||||
if (!hasFeature(file, FEATURES.decorators)) {
|
||||
throw path.buildCodeFrameError("Decorators are not enabled.");
|
||||
}
|
||||
|
||||
if (hasFeature(file, FEATURES.decorators)) {
|
||||
throw new Error(
|
||||
"@babel/plugin-class-features doesn't support decorators yet.",
|
||||
);
|
||||
if (path.isPrivate()) {
|
||||
throw path.buildCodeFrameError(
|
||||
`Private ${
|
||||
path.isClassMethod() ? "methods" : "fields"
|
||||
} in decorated classes are not supported yet.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: We can't use path.isPrivateMethod() because it isn't supported in <7.2.0
|
||||
|
||||
@@ -318,6 +318,7 @@ export function buildFieldsInitNodes(
|
||||
) {
|
||||
const staticNodes = [];
|
||||
const instanceNodes = [];
|
||||
let needsClassRef = false;
|
||||
|
||||
for (const prop of props) {
|
||||
const isStatic = prop.node.static;
|
||||
@@ -329,19 +330,23 @@ export function buildFieldsInitNodes(
|
||||
|
||||
switch (true) {
|
||||
case isStatic && isPrivate && isField && loose:
|
||||
needsClassRef = true;
|
||||
staticNodes.push(
|
||||
buildPrivateFieldInitLoose(t.cloneNode(ref), prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case isStatic && isPrivate && isField && !loose:
|
||||
needsClassRef = true;
|
||||
staticNodes.push(
|
||||
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case isStatic && isPublic && isField && loose:
|
||||
needsClassRef = true;
|
||||
staticNodes.push(buildPublicFieldInitLoose(t.cloneNode(ref), prop));
|
||||
break;
|
||||
case isStatic && isPublic && isField && !loose:
|
||||
needsClassRef = true;
|
||||
staticNodes.push(
|
||||
buildPublicFieldInitSpec(t.cloneNode(ref), prop, state),
|
||||
);
|
||||
@@ -397,5 +402,27 @@ export function buildFieldsInitNodes(
|
||||
}
|
||||
}
|
||||
|
||||
return { staticNodes, instanceNodes };
|
||||
return {
|
||||
staticNodes,
|
||||
instanceNodes,
|
||||
wrapClass(path) {
|
||||
for (const prop of props) {
|
||||
prop.remove();
|
||||
}
|
||||
|
||||
if (!needsClassRef) return path;
|
||||
|
||||
if (path.isClassExpression()) {
|
||||
path.scope.push({ id: ref });
|
||||
path.replaceWith(
|
||||
t.assignmentExpression("=", t.cloneNode(ref), path.node),
|
||||
);
|
||||
} else if (!path.node.id) {
|
||||
// Anonymous class declaration
|
||||
path.node.id = ref;
|
||||
}
|
||||
|
||||
return path;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import nameFunction from "@babel/helper-function-name";
|
||||
import { types as t } from "@babel/core";
|
||||
import splitExportDeclaration from "@babel/helper-split-export-declaration";
|
||||
import {
|
||||
buildPrivateNamesNodes,
|
||||
buildPrivateNamesMap,
|
||||
transformPrivateNamesUsage,
|
||||
buildFieldsInitNodes,
|
||||
} from "./fields";
|
||||
import {
|
||||
hasOwnDecorators,
|
||||
buildDecoratedClass,
|
||||
hasDecorators,
|
||||
} from "./decorators";
|
||||
import { injectInitialization, extractComputedKeys } from "./misc";
|
||||
import {
|
||||
enableFeature,
|
||||
@@ -54,7 +59,9 @@ export function createClassFeaturePlugin({
|
||||
const loose = isLoose(this.file, FEATURES.fields);
|
||||
|
||||
let constructor;
|
||||
let isDecorated = hasOwnDecorators(path.node);
|
||||
const props = [];
|
||||
const elements = [];
|
||||
const computedPaths = [];
|
||||
const privateNames = new Set();
|
||||
const body = path.get("body");
|
||||
@@ -75,14 +82,19 @@ export function createClassFeaturePlugin({
|
||||
privateNames.add(name);
|
||||
}
|
||||
|
||||
if (path.isProperty() || path.isPrivate()) {
|
||||
props.push(path);
|
||||
} else if (path.isClassMethod({ kind: "constructor" })) {
|
||||
if (path.isClassMethod({ kind: "constructor" })) {
|
||||
constructor = path;
|
||||
} else {
|
||||
elements.push(path);
|
||||
if (path.isProperty() || path.isPrivate()) {
|
||||
props.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isDecorated) isDecorated = hasOwnDecorators(path.node);
|
||||
}
|
||||
|
||||
if (!props.length) return;
|
||||
if (!props.length && !isDecorated) return;
|
||||
|
||||
let ref;
|
||||
|
||||
@@ -93,13 +105,9 @@ export function createClassFeaturePlugin({
|
||||
ref = path.node.id;
|
||||
}
|
||||
|
||||
const keysNodes = extractComputedKeys(
|
||||
ref,
|
||||
path,
|
||||
computedPaths,
|
||||
this.file,
|
||||
);
|
||||
|
||||
// NODE: These three functions don't support decorators yet,
|
||||
// but verifyUsedFeatures throws if there are both
|
||||
// decorators and private fields.
|
||||
const privateNamesMap = buildPrivateNamesMap(props);
|
||||
const privateNamesNodes = buildPrivateNamesNodes(
|
||||
privateNamesMap,
|
||||
@@ -109,19 +117,34 @@ export function createClassFeaturePlugin({
|
||||
|
||||
transformPrivateNamesUsage(ref, path, privateNamesMap, loose, state);
|
||||
|
||||
const { staticNodes, instanceNodes } = buildFieldsInitNodes(
|
||||
ref,
|
||||
props,
|
||||
privateNamesMap,
|
||||
state,
|
||||
loose,
|
||||
);
|
||||
let keysNodes, staticNodes, instanceNodes, wrapClass;
|
||||
|
||||
if (isDecorated) {
|
||||
staticNodes = keysNodes = [];
|
||||
({ instanceNodes, wrapClass } = buildDecoratedClass(
|
||||
ref,
|
||||
path,
|
||||
elements,
|
||||
this.file,
|
||||
));
|
||||
} else {
|
||||
keysNodes = extractComputedKeys(ref, path, computedPaths, this.file);
|
||||
({ staticNodes, instanceNodes, wrapClass } = buildFieldsInitNodes(
|
||||
ref,
|
||||
props,
|
||||
privateNamesMap,
|
||||
state,
|
||||
loose,
|
||||
));
|
||||
}
|
||||
|
||||
if (instanceNodes.length > 0) {
|
||||
injectInitialization(
|
||||
path,
|
||||
constructor,
|
||||
instanceNodes,
|
||||
(referenceVisitor, state) => {
|
||||
if (isDecorated) return;
|
||||
for (const prop of props) {
|
||||
if (prop.node.static) continue;
|
||||
prop.traverse(referenceVisitor, state);
|
||||
@@ -130,28 +153,7 @@ export function createClassFeaturePlugin({
|
||||
);
|
||||
}
|
||||
|
||||
for (const prop of props) {
|
||||
prop.remove();
|
||||
}
|
||||
|
||||
if (
|
||||
keysNodes.length === 0 &&
|
||||
staticNodes.length === 0 &&
|
||||
privateNamesNodes.length === 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.isClassExpression()) {
|
||||
path.scope.push({ id: ref });
|
||||
path.replaceWith(
|
||||
t.assignmentExpression("=", t.cloneNode(ref), path.node),
|
||||
);
|
||||
} else if (!path.node.id) {
|
||||
// Anonymous class declaration
|
||||
path.node.id = ref;
|
||||
}
|
||||
|
||||
path = wrapClass(path);
|
||||
path.insertBefore(keysNodes);
|
||||
path.insertAfter([...privateNamesNodes, ...staticNodes]);
|
||||
},
|
||||
@@ -161,6 +163,25 @@ export function createClassFeaturePlugin({
|
||||
|
||||
throw path.buildCodeFrameError(`Unknown PrivateName "${path}"`);
|
||||
},
|
||||
|
||||
ExportDefaultDeclaration(path) {
|
||||
if (this.file.get(versionKey) !== version) return;
|
||||
|
||||
const decl = path.get("declaration");
|
||||
|
||||
if (decl.isClassDeclaration() && hasDecorators(decl.node)) {
|
||||
if (decl.node.id) {
|
||||
// export default class Foo {}
|
||||
// -->
|
||||
// class Foo {} export { Foo as default }
|
||||
splitExportDeclaration(path);
|
||||
} else {
|
||||
// Annyms class declarations can be
|
||||
// transformed as if they were expressions
|
||||
decl.node.type = "ClassExpression";
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const sym = Symbol();
|
||||
const sym1 = Symbol();
|
||||
|
||||
class A {
|
||||
[sym]: A.B;
|
||||
[sym1]: Array<A>;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
"flow"
|
||||
],
|
||||
"plugins": [
|
||||
"proposal-class-properties"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
const sym = Symbol();
|
||||
const sym1 = Symbol();
|
||||
|
||||
class A {
|
||||
constructor() {
|
||||
_defineProperty(this, sym, void 0);
|
||||
|
||||
_defineProperty(this, sym1, void 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
const sym = Symbol();
|
||||
|
||||
class A {
|
||||
[sym]: A;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
"flow"
|
||||
],
|
||||
"plugins": [
|
||||
"proposal-class-properties"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
const sym = Symbol();
|
||||
|
||||
class A {
|
||||
constructor() {
|
||||
_defineProperty(this, sym, void 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-module-transforms",
|
||||
"version": "7.1.0",
|
||||
"version": "7.2.2",
|
||||
"description": "Babel helper functions for implementing ES6 module transformations",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,8 +14,8 @@
|
||||
"@babel/helper-module-imports": "^7.0.0",
|
||||
"@babel/helper-simple-access": "^7.1.0",
|
||||
"@babel/helper-split-export-declaration": "^7.0.0",
|
||||
"@babel/template": "^7.1.0",
|
||||
"@babel/types": "^7.0.0",
|
||||
"@babel/template": "^7.2.2",
|
||||
"@babel/types": "^7.2.2",
|
||||
"lodash": "^4.17.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ export type ModuleMetadata = {
|
||||
// The name of the variable that will reference an object containing export names.
|
||||
exportNameListName: null | string,
|
||||
|
||||
hasExports: boolean,
|
||||
|
||||
// Lookup from local binding to export information.
|
||||
local: Map<string, LocalExportMetadata>,
|
||||
|
||||
@@ -52,18 +54,7 @@ export type LocalExportMetadata = {
|
||||
* Check if the module has any exports that need handling.
|
||||
*/
|
||||
export function hasExports(metadata: ModuleMetadata) {
|
||||
const { local, source } = metadata;
|
||||
|
||||
return (
|
||||
local.size > 0 ||
|
||||
Array.from(source).some(([, meta]) => {
|
||||
return (
|
||||
meta.reexports.size > 0 ||
|
||||
meta.reexportNamespace.size > 0 ||
|
||||
!!meta.reexportAll
|
||||
);
|
||||
})
|
||||
);
|
||||
return metadata.hasExports;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +90,10 @@ export default function normalizeModuleAndLoadMetadata(
|
||||
|
||||
nameAnonymousExports(programPath);
|
||||
|
||||
const { local, source } = getModuleMetadata(programPath, { loose, lazy });
|
||||
const { local, source, hasExports } = getModuleMetadata(programPath, {
|
||||
loose,
|
||||
lazy,
|
||||
});
|
||||
|
||||
removeModuleDeclarations(programPath);
|
||||
|
||||
@@ -127,6 +121,7 @@ export default function normalizeModuleAndLoadMetadata(
|
||||
return {
|
||||
exportName,
|
||||
exportNameListName: null,
|
||||
hasExports,
|
||||
local,
|
||||
source,
|
||||
};
|
||||
@@ -171,6 +166,7 @@ function getModuleMetadata(
|
||||
}
|
||||
return data;
|
||||
};
|
||||
let hasExports = false;
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isImportDeclaration()) {
|
||||
const data = getData(child.node.source);
|
||||
@@ -219,6 +215,7 @@ function getModuleMetadata(
|
||||
}
|
||||
});
|
||||
} else if (child.isExportAllDeclaration()) {
|
||||
hasExports = true;
|
||||
const data = getData(child.node.source);
|
||||
if (!data.loc) data.loc = child.node.loc;
|
||||
|
||||
@@ -226,6 +223,7 @@ function getModuleMetadata(
|
||||
loc: child.node.loc,
|
||||
};
|
||||
} else if (child.isExportNamedDeclaration() && child.node.source) {
|
||||
hasExports = true;
|
||||
const data = getData(child.node.source);
|
||||
if (!data.loc) data.loc = child.node.loc;
|
||||
|
||||
@@ -242,6 +240,11 @@ function getModuleMetadata(
|
||||
throw exportName.buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
});
|
||||
} else if (
|
||||
child.isExportNamedDeclaration() ||
|
||||
child.isExportDefaultDeclaration()
|
||||
) {
|
||||
hasExports = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -295,6 +298,7 @@ function getModuleMetadata(
|
||||
}
|
||||
|
||||
return {
|
||||
hasExports,
|
||||
local: localData,
|
||||
source: sourceData,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-replace-supers",
|
||||
"version": "7.1.0",
|
||||
"version": "7.2.3",
|
||||
"description": "Helper function to replace supers",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers",
|
||||
"license": "MIT",
|
||||
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@babel/helper-member-expression-to-functions": "^7.0.0",
|
||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
||||
"@babel/traverse": "^7.1.0",
|
||||
"@babel/traverse": "^7.2.3",
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ function skipAllButComputedKey(path) {
|
||||
}
|
||||
|
||||
export const environmentVisitor = {
|
||||
TypeAnnotation(path) {
|
||||
path.skip();
|
||||
},
|
||||
Function(path) {
|
||||
// Methods will be handled by the Method visit
|
||||
if (path.isMethod()) return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/node",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.2",
|
||||
"description": "Babel command line",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -29,7 +29,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/helper-fixtures": "^7.2.0",
|
||||
"fs-readdir-recursive": "^1.0.0",
|
||||
"output-file-sync": "^2.0.0"
|
||||
|
||||
@@ -52,7 +52,7 @@ program.option(
|
||||
"The name of the 'env' to use when loading configs and plugins. " +
|
||||
"Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.",
|
||||
);
|
||||
commander.option(
|
||||
program.option(
|
||||
"--root-mode [mode]",
|
||||
"The project-root resolution mode. " +
|
||||
"One of 'root' (the default), 'upward', or 'upward-optional'.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.3",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -1759,7 +1759,7 @@ export default class ExpressionParser extends LValParser {
|
||||
parseArrowExpression(
|
||||
node: N.ArrowFunctionExpression,
|
||||
params?: ?(N.Expression[]),
|
||||
isAsync?: boolean,
|
||||
isAsync?: boolean = false,
|
||||
): N.ArrowFunctionExpression {
|
||||
// if we got there, it's no more "yield in possible arrow parameters";
|
||||
// it's just "yield in arrow parameters"
|
||||
|
||||
@@ -896,9 +896,9 @@ export default class StatementParser extends ExpressionParser {
|
||||
parseFunction<T: N.NormalFunction>(
|
||||
node: T,
|
||||
isStatement: boolean,
|
||||
allowExpressionBody?: boolean,
|
||||
isAsync?: boolean,
|
||||
optionalId?: boolean,
|
||||
allowExpressionBody?: boolean = false,
|
||||
isAsync?: boolean = false,
|
||||
optionalId?: boolean = false,
|
||||
): T {
|
||||
const oldInFunc = this.state.inFunction;
|
||||
const oldInMethod = this.state.inMethod;
|
||||
|
||||
@@ -300,7 +300,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
if (node) {
|
||||
node.type = "Property";
|
||||
if (node.kind === "method") node.kind = "init";
|
||||
if (((node: any): N.ClassMethod).kind === "method") node.kind = "init";
|
||||
node.shorthand = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1384,6 +1384,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
default:
|
||||
if (this.state.type.keyword === "typeof") {
|
||||
return this.flowParseTypeofType();
|
||||
} else if (this.state.type.keyword) {
|
||||
const label = this.state.type.label;
|
||||
this.next();
|
||||
return super.createIdentifier(node, label);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1842,7 +1846,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
super.assertModuleNodeAllowed(node);
|
||||
}
|
||||
|
||||
parseExport(node: N.ExportNamedDeclaration): N.ExportNamedDeclaration {
|
||||
parseExport(
|
||||
node: N.ExportNamedDeclaration | N.ExportAllDeclaration,
|
||||
): N.ExportNamedDeclaration | N.ExportAllDeclaration {
|
||||
node = super.parseExport(node);
|
||||
if (
|
||||
node.type === "ExportNamedDeclaration" ||
|
||||
@@ -2695,21 +2701,34 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
super.readToken_mult_modulo(code);
|
||||
}
|
||||
|
||||
parseTopLevel(file: N.File, program: N.Program): N.File {
|
||||
const fileNode = super.parseTopLevel(file, program);
|
||||
if (this.state.hasFlowComment) {
|
||||
this.unexpected(null, "Unterminated flow-comment");
|
||||
}
|
||||
return fileNode;
|
||||
}
|
||||
|
||||
skipBlockComment(): void {
|
||||
if (
|
||||
this.hasPlugin("flow") &&
|
||||
this.hasPlugin("flowComments") &&
|
||||
this.skipFlowComment()
|
||||
) {
|
||||
if (this.state.hasFlowComment) {
|
||||
this.unexpected(
|
||||
null,
|
||||
"Cannot have a flow comment inside another flow comment",
|
||||
);
|
||||
}
|
||||
this.hasFlowCommentCompletion();
|
||||
this.state.pos += this.skipFlowComment();
|
||||
this.state.hasFlowComment = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let end;
|
||||
if (this.hasPlugin("flow") && this.state.hasFlowComment) {
|
||||
end = this.input.indexOf("*-/", (this.state.pos += 2));
|
||||
const end = this.input.indexOf("*-/", (this.state.pos += 2));
|
||||
if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment");
|
||||
this.state.pos = end + 3;
|
||||
return;
|
||||
@@ -2719,17 +2738,32 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
skipFlowComment(): number | boolean {
|
||||
const ch2 = this.input.charCodeAt(this.state.pos + 2);
|
||||
const ch3 = this.input.charCodeAt(this.state.pos + 3);
|
||||
const { pos } = this.state;
|
||||
let shiftToFirstNonWhiteSpace = 2;
|
||||
while (
|
||||
[charCodes.space, charCodes.tab].includes(
|
||||
this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace),
|
||||
)
|
||||
) {
|
||||
shiftToFirstNonWhiteSpace++;
|
||||
}
|
||||
|
||||
const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
|
||||
const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
|
||||
|
||||
if (ch2 === charCodes.colon && ch3 === charCodes.colon) {
|
||||
return 4; // check for /*::
|
||||
return shiftToFirstNonWhiteSpace + 2; // check for /*::
|
||||
}
|
||||
if (this.input.slice(this.state.pos + 2, 14) === "flow-include") {
|
||||
return 14; // check for /*flow-include
|
||||
if (
|
||||
this.input.slice(
|
||||
shiftToFirstNonWhiteSpace + pos,
|
||||
shiftToFirstNonWhiteSpace + pos + 12,
|
||||
) === "flow-include"
|
||||
) {
|
||||
return shiftToFirstNonWhiteSpace + 12; // check for /*flow-include
|
||||
}
|
||||
if (ch2 === charCodes.colon && ch3 !== charCodes.colon) {
|
||||
return 2; // check for /*:, advance only 2 steps
|
||||
return shiftToFirstNonWhiteSpace; // check for /*:, advance up to :
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,10 @@ export default class State {
|
||||
// The first yield or await expression inside parenthesized expressions
|
||||
// and arrow function parameters. It is used to disallow yield and await in
|
||||
// arrow function parameters.
|
||||
yieldOrAwaitInPossibleArrowParameters: ?N.YieldExpression;
|
||||
yieldOrAwaitInPossibleArrowParameters:
|
||||
| N.YieldExpression
|
||||
| N.AwaitExpression
|
||||
| null;
|
||||
|
||||
// Token store.
|
||||
tokens: Array<Token | N.Comment>;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class MyClass {
|
||||
/*:: prop: string; */
|
||||
/* :: foo: number; */
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -32,14 +32,14 @@
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -64,14 +64,14 @@
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 14,
|
||||
"end": 41,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -92,6 +92,22 @@
|
||||
"column": 23
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " :: foo: number; ",
|
||||
"start": 42,
|
||||
"end": 66,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 26
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -115,6 +131,22 @@
|
||||
"column": 23
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " :: foo: number; ",
|
||||
"start": 42,
|
||||
"end": 66,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 26
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/*flow-include
|
||||
/* flow-include
|
||||
type Foo = {
|
||||
foo: number,
|
||||
bar: boolean,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 78,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -15,7 +15,7 @@
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 78,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -33,9 +33,9 @@
|
||||
"innerComments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": "flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n",
|
||||
"value": " flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n",
|
||||
"start": 0,
|
||||
"end": 78,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -52,9 +52,9 @@
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": "flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n",
|
||||
"value": " flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n",
|
||||
"start": 0,
|
||||
"end": 78,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class MyClass {
|
||||
/*flow-include prop: string; */
|
||||
/* flow-include foo: number; */
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"end": 90,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"end": 90,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -32,14 +32,14 @@
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"end": 90,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -64,14 +64,14 @@
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 14,
|
||||
"end": 51,
|
||||
"end": 90,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -92,6 +92,22 @@
|
||||
"column": 33
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " flow-include foo: number; ",
|
||||
"start": 52,
|
||||
"end": 88,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 38
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -115,6 +131,22 @@
|
||||
"column": 33
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " flow-include foo: number; ",
|
||||
"start": 52,
|
||||
"end": 88,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 38
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
class MyClass {
|
||||
/*:: prop: string; */
|
||||
/* :: prop: string; */
|
||||
/* :: prop2: number; */
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -32,14 +32,14 @@
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -64,45 +64,45 @@
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 14,
|
||||
"end": 41,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start": 23,
|
||||
"end": 36,
|
||||
"start": 26,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 23,
|
||||
"end": 27,
|
||||
"start": 26,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
"column": 14
|
||||
},
|
||||
"identifierName": "prop"
|
||||
},
|
||||
@@ -112,30 +112,96 @@
|
||||
"variance": null,
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 27,
|
||||
"end": 35,
|
||||
"start": 30,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 19
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start": 29,
|
||||
"end": 35,
|
||||
"start": 32,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start": 55,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 55,
|
||||
"end": 60,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "prop2"
|
||||
},
|
||||
"name": "prop2"
|
||||
},
|
||||
"computed": false,
|
||||
"variance": null,
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 60,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 62,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*flow-include
|
||||
/* flow-include
|
||||
type Foo = {
|
||||
foo: number,
|
||||
bar: boolean,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 78,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -15,7 +15,7 @@
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 78,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -31,8 +31,8 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start": 15,
|
||||
"end": 75,
|
||||
"start": 16,
|
||||
"end": 76,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -45,8 +45,8 @@
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 20,
|
||||
"end": 23,
|
||||
"start": 21,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -63,8 +63,8 @@
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 26,
|
||||
"end": 74,
|
||||
"start": 27,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -79,8 +79,8 @@
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start": 30,
|
||||
"end": 41,
|
||||
"start": 31,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
@@ -93,8 +93,8 @@
|
||||
},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 30,
|
||||
"end": 33,
|
||||
"start": 31,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
@@ -114,8 +114,8 @@
|
||||
"method": false,
|
||||
"value": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 35,
|
||||
"end": 41,
|
||||
"start": 36,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
@@ -132,8 +132,8 @@
|
||||
},
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start": 45,
|
||||
"end": 57,
|
||||
"start": 46,
|
||||
"end": 58,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
@@ -146,8 +146,8 @@
|
||||
},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 45,
|
||||
"end": 48,
|
||||
"start": 46,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
@@ -167,8 +167,8 @@
|
||||
"method": false,
|
||||
"value": {
|
||||
"type": "BooleanTypeAnnotation",
|
||||
"start": 50,
|
||||
"end": 57,
|
||||
"start": 51,
|
||||
"end": 58,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
@@ -185,8 +185,8 @@
|
||||
},
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start": 61,
|
||||
"end": 72,
|
||||
"start": 62,
|
||||
"end": 73,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
@@ -199,8 +199,8 @@
|
||||
},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 61,
|
||||
"end": 64,
|
||||
"start": 62,
|
||||
"end": 65,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
@@ -220,8 +220,8 @@
|
||||
"method": false,
|
||||
"value": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start": 66,
|
||||
"end": 72,
|
||||
"start": 67,
|
||||
"end": 73,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class MyClass {
|
||||
/*flow-include prop: string; */
|
||||
/* flow-include prop: string; */
|
||||
/* flow-include prop2: number; */
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"end": 99,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"end": 99,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -32,14 +32,14 @@
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"end": 99,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
@@ -64,57 +64,154 @@
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 14,
|
||||
"end": 51,
|
||||
"end": 99,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"innerComments": [
|
||||
"body": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": "flow-include prop: string; ",
|
||||
"start": 18,
|
||||
"end": 49,
|
||||
"type": "ClassProperty",
|
||||
"start": 39,
|
||||
"end": 52,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
"column": 36
|
||||
}
|
||||
}
|
||||
},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 39,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"identifierName": "prop"
|
||||
},
|
||||
"name": "prop"
|
||||
},
|
||||
"computed": false,
|
||||
"variance": null,
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 43,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start": 45,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start": 80,
|
||||
"end": 94,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 80,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
},
|
||||
"identifierName": "prop2"
|
||||
},
|
||||
"name": "prop2"
|
||||
},
|
||||
"computed": false,
|
||||
"variance": null,
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 85,
|
||||
"end": 93,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 37
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 87,
|
||||
"end": 93,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 31
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 37
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": "flow-include prop: string; ",
|
||||
"start": 18,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
class MyClass {
|
||||
/*:: prop: string;
|
||||
/* :: prop: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*flow-include
|
||||
/* flow-include
|
||||
type Foo = {
|
||||
foo: number,
|
||||
bar: boolean,
|
||||
|
||||
1
packages/babel-parser/test/fixtures/flow/comment/11-nested-comments-invalid/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/comment/11-nested-comments-invalid/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/*:: /*asd */
|
||||
3
packages/babel-parser/test/fixtures/flow/comment/11-nested-comments-invalid/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/comment/11-nested-comments-invalid/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unterminated comment (1:5)"
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/*:: //asd */
|
||||
3
packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unterminated flow-comment (1:13)"
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/comment/13-nested-flow-comments-invalid/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/comment/13-nested-flow-comments-invalid/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/*:: /*flow-include */
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot have a flow comment inside another flow comment (1:0)"
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:23)"
|
||||
"throws": "Unexpected token, expected \";\" (1:27)"
|
||||
}
|
||||
|
||||
1
packages/babel-parser/test/fixtures/flow/type-annotations/function-is-valid-type/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/type-annotations/function-is-valid-type/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function foo(a:function) {}
|
||||
137
packages/babel-parser/test/fixtures/flow/type-annotations/function-is-valid-type/output.json
vendored
Normal file
137
packages/babel-parser/test/fixtures/flow/type-annotations/function-is-valid-type/output.json
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 14,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 25,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-proposal-class-properties",
|
||||
"version": "7.2.1",
|
||||
"version": "7.2.3",
|
||||
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties",
|
||||
"license": "MIT",
|
||||
@@ -12,7 +12,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.1",
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.3",
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* eslint-disable local-rules/plugin-name */
|
||||
/* eslint-disable @babel/development/plugin-name */
|
||||
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
var _class;
|
||||
|
||||
class MyClass {
|
||||
constructor() {
|
||||
var _this = this;
|
||||
@@ -22,7 +20,7 @@ class MyClass {
|
||||
|
||||
var _myAsyncMethod = new WeakMap();
|
||||
|
||||
_class = class MyClass2 {
|
||||
(class MyClass2 {
|
||||
constructor() {
|
||||
var _this2 = this;
|
||||
|
||||
@@ -40,7 +38,7 @@ _class = class MyClass2 {
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
var _myAsyncMethod2 = new WeakMap();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var _class, _descriptor, _class2, _Symbol$search, _temp;
|
||||
var _class, _descriptor, _Symbol$search, _temp;
|
||||
|
||||
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
||||
|
||||
@@ -14,7 +14,7 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
|
||||
|
||||
function dec() {}
|
||||
|
||||
let A = (_class = (_temp = (_Symbol$search = Symbol.search, _class2 =
|
||||
let A = (_class = (_temp = (_Symbol$search = Symbol.search,
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-proposal-decorators",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.3",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
@@ -15,16 +15,15 @@
|
||||
"decorators"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.3",
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/helper-replace-supers": "^7.1.0",
|
||||
"@babel/helper-split-export-declaration": "^7.0.0",
|
||||
"@babel/plugin-syntax-decorators": "^7.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/* eslint-disable @babel/development/plugin-name */
|
||||
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
import syntaxDecorators from "@babel/plugin-syntax-decorators";
|
||||
import visitor from "./transformer";
|
||||
import {
|
||||
createClassFeaturePlugin,
|
||||
FEATURES,
|
||||
} from "@babel/helper-create-class-features-plugin";
|
||||
import legacyVisitor from "./transformer-legacy";
|
||||
|
||||
export default declare((api, options) => {
|
||||
@@ -31,14 +36,26 @@ export default declare((api, options) => {
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name: "proposal-decorators",
|
||||
inherits: syntaxDecorators,
|
||||
if (legacy) {
|
||||
return {
|
||||
name: "proposal-decorators",
|
||||
inherits: syntaxDecorators,
|
||||
manipulateOptions({ generatorOpts }) {
|
||||
generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
|
||||
},
|
||||
visitor: legacyVisitor,
|
||||
};
|
||||
}
|
||||
|
||||
manipulateOptions({ generatorOpts }) {
|
||||
return createClassFeaturePlugin({
|
||||
name: "proposal-decorators",
|
||||
|
||||
feature: FEATURES.decorators,
|
||||
// loose: options.loose, Not supported
|
||||
|
||||
manipulateOptions({ generatorOpts, parserOpts }) {
|
||||
parserOpts.plugins.push(["decorators", { decoratorsBeforeExport }]);
|
||||
generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
|
||||
},
|
||||
|
||||
visitor: legacy ? legacyVisitor : visitor,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
import { types as t, template } from "@babel/core";
|
||||
import splitExportDeclaration from "@babel/helper-split-export-declaration";
|
||||
import ReplaceSupers from "@babel/helper-replace-supers";
|
||||
|
||||
function prop(key, value) {
|
||||
if (!value) return null;
|
||||
return t.objectProperty(t.identifier(key), value);
|
||||
}
|
||||
|
||||
function value(body, params = [], async, generator) {
|
||||
const method = t.objectMethod("method", t.identifier("value"), params, body);
|
||||
method.async = !!async;
|
||||
method.generator = !!generator;
|
||||
return method;
|
||||
}
|
||||
|
||||
function hasDecorators({ node }) {
|
||||
if (node.decorators && node.decorators.length > 0) return true;
|
||||
|
||||
const body = node.body.body;
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const method = body[i];
|
||||
if (method.decorators && method.decorators.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function takeDecorators({ node }) {
|
||||
let result;
|
||||
if (node.decorators && node.decorators.length > 0) {
|
||||
result = t.arrayExpression(
|
||||
node.decorators.map(decorator => decorator.expression),
|
||||
);
|
||||
}
|
||||
node.decorators = undefined;
|
||||
return result;
|
||||
}
|
||||
|
||||
function getKey(node) {
|
||||
if (node.computed) {
|
||||
return node.key;
|
||||
} else if (t.isIdentifier(node.key)) {
|
||||
return t.stringLiteral(node.key.name);
|
||||
} else {
|
||||
return t.stringLiteral(String(node.key.value));
|
||||
}
|
||||
}
|
||||
|
||||
function getSingleElementDefinition(path, superRef, classRef, file) {
|
||||
const { node, scope } = path;
|
||||
const isMethod = path.isClassMethod();
|
||||
|
||||
if (path.isPrivate()) {
|
||||
throw path.buildCodeFrameError(
|
||||
`Private ${
|
||||
isMethod ? "methods" : "fields"
|
||||
} in decorated classes are not supported yet.`,
|
||||
);
|
||||
}
|
||||
|
||||
new ReplaceSupers(
|
||||
{
|
||||
methodPath: path,
|
||||
methodNode: node,
|
||||
objectRef: classRef,
|
||||
isStatic: node.static,
|
||||
superRef,
|
||||
scope,
|
||||
file,
|
||||
},
|
||||
true,
|
||||
).replace();
|
||||
|
||||
const properties = [
|
||||
prop("kind", t.stringLiteral(isMethod ? node.kind : "field")),
|
||||
prop("decorators", takeDecorators(path)),
|
||||
prop("static", node.static && t.booleanLiteral(true)),
|
||||
prop("key", getKey(node)),
|
||||
isMethod
|
||||
? value(node.body, node.params, node.async, node.generator)
|
||||
: node.value
|
||||
? value(template.ast`{ return ${node.value} }`)
|
||||
: prop("value", scope.buildUndefinedNode()),
|
||||
].filter(Boolean);
|
||||
|
||||
return t.objectExpression(properties);
|
||||
}
|
||||
|
||||
function getElementsDefinitions(path, fId, file) {
|
||||
const elements = [];
|
||||
for (const p of path.get("body.body")) {
|
||||
if (!p.isClassMethod({ kind: "constructor" })) {
|
||||
elements.push(
|
||||
getSingleElementDefinition(p, path.node.superClass, fId, file),
|
||||
);
|
||||
p.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return t.arrayExpression(elements);
|
||||
}
|
||||
|
||||
function getConstructorPath(path) {
|
||||
return path
|
||||
.get("body.body")
|
||||
.find(path => path.isClassMethod({ kind: "constructor" }));
|
||||
}
|
||||
|
||||
const bareSupersVisitor = {
|
||||
CallExpression(path, { initializeInstanceElements }) {
|
||||
if (path.get("callee").isSuper()) {
|
||||
path.insertAfter(t.cloneNode(initializeInstanceElements));
|
||||
|
||||
// Sometimes this path gets requeued (e.g. in (super(), foo)), and
|
||||
// it leads to infinite recursion.
|
||||
path.skip();
|
||||
}
|
||||
},
|
||||
Function(path) {
|
||||
if (!path.isArrowFunctionExpression()) path.skip();
|
||||
},
|
||||
};
|
||||
|
||||
function insertInitializeInstanceElements(path, initializeInstanceId) {
|
||||
const isBase = !path.node.superClass;
|
||||
const initializeInstanceElements = t.callExpression(initializeInstanceId, [
|
||||
t.thisExpression(),
|
||||
]);
|
||||
|
||||
const constructorPath = getConstructorPath(path);
|
||||
if (constructorPath) {
|
||||
if (isBase) {
|
||||
constructorPath
|
||||
.get("body")
|
||||
.unshiftContainer("body", [
|
||||
t.expressionStatement(initializeInstanceElements),
|
||||
]);
|
||||
} else {
|
||||
constructorPath.traverse(bareSupersVisitor, {
|
||||
initializeInstanceElements,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const constructor = isBase
|
||||
? t.classMethod(
|
||||
"constructor",
|
||||
t.identifier("constructor"),
|
||||
[],
|
||||
t.blockStatement([t.expressionStatement(initializeInstanceElements)]),
|
||||
)
|
||||
: t.classMethod(
|
||||
"constructor",
|
||||
t.identifier("constructor"),
|
||||
[t.restElement(t.identifier("args"))],
|
||||
t.blockStatement([
|
||||
t.expressionStatement(
|
||||
t.callExpression(t.Super(), [
|
||||
t.spreadElement(t.identifier("args")),
|
||||
]),
|
||||
),
|
||||
t.expressionStatement(initializeInstanceElements),
|
||||
]),
|
||||
);
|
||||
path.node.body.body.push(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
function transformClass(path, file) {
|
||||
const isDeclaration = path.node.id && path.isDeclaration();
|
||||
const isStrict = path.isInStrictMode();
|
||||
const { superClass } = path.node;
|
||||
|
||||
path.node.type = "ClassDeclaration";
|
||||
if (!path.node.id) path.node.id = path.scope.generateUidIdentifier("class");
|
||||
|
||||
const initializeId = path.scope.generateUidIdentifier("initialize");
|
||||
const superId =
|
||||
superClass &&
|
||||
path.scope.generateUidIdentifierBasedOnNode(path.node.superClass, "super");
|
||||
|
||||
if (superClass) path.node.superClass = superId;
|
||||
|
||||
const classDecorators = takeDecorators(path);
|
||||
const definitions = getElementsDefinitions(path, path.node.id, file);
|
||||
|
||||
insertInitializeInstanceElements(path, initializeId);
|
||||
|
||||
const expr = template.expression.ast`
|
||||
${addDecorateHelper(file)}(
|
||||
${classDecorators || t.nullLiteral()},
|
||||
function (${initializeId}, ${superClass ? superId : null}) {
|
||||
${path.node}
|
||||
return { F: ${t.cloneNode(path.node.id)}, d: ${definitions} };
|
||||
},
|
||||
${superClass}
|
||||
)
|
||||
`;
|
||||
if (!isStrict) {
|
||||
expr.arguments[1].body.directives.push(
|
||||
t.directive(t.directiveLiteral("use strict")),
|
||||
);
|
||||
}
|
||||
|
||||
return isDeclaration ? template.ast`let ${path.node.id} = ${expr}` : expr;
|
||||
}
|
||||
|
||||
function addDecorateHelper(file) {
|
||||
try {
|
||||
return file.addHelper("decorate");
|
||||
} catch (err) {
|
||||
if (err.code === "BABEL_HELPER_UNKNOWN") {
|
||||
err.message +=
|
||||
"\n '@babel/plugin-transform-decorators' in non-legacy mode" +
|
||||
" requires '@babel/core' version ^7.0.2 and you appear to be using" +
|
||||
" an older version.";
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
ExportDefaultDeclaration(path) {
|
||||
let decl = path.get("declaration");
|
||||
if (!decl.isClassDeclaration() || !hasDecorators(decl)) return;
|
||||
|
||||
if (decl.node.id) decl = splitExportDeclaration(path);
|
||||
|
||||
decl.replaceWith(transformClass(decl, this.file));
|
||||
},
|
||||
|
||||
Class(path) {
|
||||
if (hasDecorators(path)) {
|
||||
path.replaceWith(transformClass(path, this.file));
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
"version": "7.2.0",
|
||||
"description": "Remove nullish coalescing operator",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-nullish-coalescing-opearator",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-nullish-coalescing-operator",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-proposal-private-methods",
|
||||
"version": "7.2.1",
|
||||
"version": "7.2.3",
|
||||
"description": "This plugin transforms private class methods",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-private-methods",
|
||||
"license": "MIT",
|
||||
@@ -12,7 +12,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.1",
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.3",
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* eslint-disable local-rules/plugin-name */
|
||||
/* eslint-disable @babel/development/plugin-name */
|
||||
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
import {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@babel/plugin-syntax-bigint",
|
||||
"version": "7.2.0",
|
||||
"description": "Allow parsing of BigInt literals",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-bigint",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-bigint",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -15,9 +15,10 @@ class Foo extends function () {} {
|
||||
};
|
||||
|
||||
if (true) {
|
||||
console.log(_this2 = super(), foo());
|
||||
console.log((super(), _this2 = this), foo());
|
||||
} else {
|
||||
_this2 = super();
|
||||
super();
|
||||
_this2 = this;
|
||||
console.log(foo());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-classes",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.2",
|
||||
"description": "Compile ES2015 classes to ES5",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-classes",
|
||||
"license": "MIT",
|
||||
@@ -25,7 +25,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +494,8 @@ export default function transformClass(
|
||||
node.generator,
|
||||
node.async,
|
||||
);
|
||||
func.returnType = node.returnType;
|
||||
t.inherits(func, node);
|
||||
|
||||
const key = t.toComputedKey(node, node.key);
|
||||
if (t.isStringLiteral(key)) {
|
||||
func = nameFunction({
|
||||
|
||||
@@ -21,7 +21,7 @@ var _ref4 = [a[1], a[0]];
|
||||
a[0] = _ref4[0];
|
||||
a[1] = _ref4[1];
|
||||
|
||||
var _ref5 = babelHelpers.toConsumableArray(foo).concat([bar]),
|
||||
var _ref5 = [].concat(babelHelpers.toConsumableArray(foo), [bar]),
|
||||
a = _ref5[0],
|
||||
b = _ref5[1];
|
||||
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
"regular expressions",
|
||||
"dotall"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-dotall-regex.git"
|
||||
},
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-dotall-regex",
|
||||
"bugs": "https://github.com/babel/babel/issues",
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-flow-strip-types",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.3",
|
||||
"description": "Strip flow type annotations from your output code.",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-flow-strip-types",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { types as t } from "@babel/core";
|
||||
export default declare(api => {
|
||||
api.assertVersion(7);
|
||||
|
||||
const FLOW_DIRECTIVE = "@flow";
|
||||
const FLOW_DIRECTIVE = /(@flow(\s+(strict(-local)?|weak))?|@noflow)/;
|
||||
|
||||
let skipStrip = false;
|
||||
|
||||
@@ -28,7 +28,7 @@ export default declare(api => {
|
||||
|
||||
if (comments) {
|
||||
for (const comment of (comments: Array<Object>)) {
|
||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
||||
if (FLOW_DIRECTIVE.test(comment.value)) {
|
||||
directiveFound = true;
|
||||
|
||||
// remove flow directive
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// @noflow
|
||||
const a = 1;
|
||||
@@ -0,0 +1 @@
|
||||
const a = 1;
|
||||
@@ -0,0 +1,2 @@
|
||||
// @flow strict-local
|
||||
const a = 1;
|
||||
@@ -0,0 +1 @@
|
||||
const a = 1;
|
||||
@@ -0,0 +1,2 @@
|
||||
// @flow strict
|
||||
const a = 1;
|
||||
@@ -0,0 +1 @@
|
||||
const a = 1;
|
||||
@@ -0,0 +1,2 @@
|
||||
// @flow weak
|
||||
const a = 1;
|
||||
@@ -0,0 +1 @@
|
||||
const a = 1;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
var _interopRequireDefault3 = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _interopRequireDefault2 = _interopRequireDefault3(require("@babel/runtime/helpers/interopRequireDefault"));
|
||||
|
||||
console.log(_interopRequireDefault2.default);
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
var _interopRequireDefault3 = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _interopRequireDefault2 = _interopRequireDefault3(require("@babel/runtime/helpers/interopRequireDefault"));
|
||||
|
||||
console.log(_interopRequireDefault2.default);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user