Skip to content

Commit 2b8f4ef

Browse files
committed
Update babel parser
1 parent 3384c08 commit 2b8f4ef

File tree

7 files changed

+1219
-765
lines changed

7 files changed

+1219
-765
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"presets": [
3-
["env", {
3+
["@babel/preset-env", {
44
"targets": {
55
"node": 6
66
},
77
"include": ["transform-regenerator"]
88
}],
9-
"flow"
9+
"@babel/preset-flow"
1010
],
1111
"plugins": ["syntax-async-functions"],
1212
"ignore": [

__tests__/lib/flow_doctrine.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ test('flowDoctrine', function() {
304304
expect(types).toEqual([
305305
'IntersectionTypeAnnotation',
306306
'EmptyTypeAnnotation',
307+
'NumericLiteralTypeAnnotation',
307308
'TypeofTypeAnnotation'
308309
]);
309310
});

package.json

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,34 @@
77
"documentation": "./bin/documentation.js"
88
},
99
"dependencies": {
10+
"@babel/core": "^7.0.0-rc.3",
11+
"@babel/generator": "^7.0.0-rc.3",
12+
"@babel/parser": "^7.0.0-beta.55",
13+
"@babel/plugin-proposal-class-properties": "^7.0.0-rc.3",
14+
"@babel/plugin-proposal-decorators": "^7.0.0-rc.3",
15+
"@babel/plugin-proposal-do-expressions": "^7.0.0-rc.3",
16+
"@babel/plugin-proposal-export-default-from": "^7.0.0-rc.3",
17+
"@babel/plugin-proposal-export-namespace-from": "^7.0.0-rc.3",
18+
"@babel/plugin-proposal-function-bind": "^7.0.0-rc.3",
19+
"@babel/plugin-proposal-function-sent": "^7.0.0-rc.3",
20+
"@babel/plugin-proposal-json-strings": "^7.0.0-rc.3",
21+
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0-rc.3",
22+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0-rc.3",
23+
"@babel/plugin-proposal-numeric-separator": "^7.0.0-rc.3",
24+
"@babel/plugin-proposal-optional-chaining": "^7.0.0-rc.3",
25+
"@babel/plugin-proposal-pipeline-operator": "^7.0.0-rc.3",
26+
"@babel/plugin-proposal-throw-expressions": "^7.0.0-rc.3",
27+
"@babel/plugin-syntax-dynamic-import": "^7.0.0-rc.3",
28+
"@babel/plugin-syntax-import-meta": "^7.0.0-rc.3",
29+
"@babel/preset-env": "^7.0.0-rc.3",
30+
"@babel/preset-flow": "^7.0.0-rc.3",
31+
"@babel/preset-react": "^7.0.0-rc.3",
32+
"@babel/preset-stage-0": "^7.0.0-rc.3",
1033
"ansi-html": "^0.0.7",
11-
"babel-core": "^6.26.0",
12-
"babel-generator": "^6.26.0",
1334
"babel-plugin-system-import-transformer": "3.1.0",
14-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
15-
"babel-preset-env": "^1.6.1",
16-
"babel-preset-react": "^6.24.1",
17-
"babel-preset-stage-0": "^6.24.1",
1835
"babel-traverse": "^6.26.0",
1936
"babel-types": "^6.26.0",
20-
"babelify": "^8.0.0",
21-
"babylon": "^6.18.0",
37+
"babelify": "^9.0.0",
2238
"chalk": "^2.3.0",
2339
"chokidar": "^2.0.0",
2440
"concat-stream": "^1.6.0",
@@ -58,13 +74,13 @@
5874
"yargs": "^9.0.1"
5975
},
6076
"devDependencies": {
77+
"@babel/cli": "^7.0.0-rc.3",
6178
"are-we-flow-yet": "^1.0.0",
62-
"babel-cli": "^6.26.0",
79+
"babel-core": "^7.0.0-0",
6380
"babel-eslint": "^8.2.1",
64-
"babel-jest": "^23.0.1",
81+
"babel-jest": "^23.4.2",
6582
"babel-plugin-syntax-async-functions": "^6.13.0",
6683
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
67-
"babel-preset-flow": "^6.23.0",
6884
"chdir": "0.0.0",
6985
"coveralls": "^3.0.0",
7086
"cz-conventional-changelog": "2.1.0",

src/flow_doctrine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
const generate = require('babel-generator').default;
3+
const generate = require('@babel/generator').default;
44

55
const namedTypes = {
66
NumberTypeAnnotation: 'number',
@@ -142,7 +142,7 @@ function flowDoctrine(type: Object): DoctrineType {
142142
type: 'BooleanLiteralType',
143143
value: type.value
144144
};
145-
case 'NumericLiteralTypeAnnotation':
145+
case 'NumberLiteralTypeAnnotation':
146146
return {
147147
type: 'NumericLiteralType',
148148
value: type.value

src/input/dependency.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,33 @@ function dependencyStream(
3535
.concat(['.mjs', '.js', '.json', '.es6', '.jsx']),
3636
transform: [
3737
babelify.configure({
38-
sourceMap: false,
38+
sourceMaps: false,
3939
compact: false,
40-
presets: [
41-
require('babel-preset-env'),
42-
require('babel-preset-stage-0'),
43-
require('babel-preset-react')
44-
],
40+
presets: ['@babel/preset-react', '@babel/preset-env'],
4541
plugins: [
46-
require('babel-plugin-transform-decorators-legacy').default,
47-
// Required to support webpack's System.import
48-
// https://github.com/documentationjs/documentation/issues/578
49-
require('babel-plugin-system-import-transformer').default
42+
// Stage 0
43+
'@babel/plugin-proposal-function-bind',
44+
// Stage 1
45+
'@babel/plugin-proposal-export-default-from',
46+
'@babel/plugin-proposal-logical-assignment-operators',
47+
['@babel/plugin-proposal-optional-chaining', { loose: false }],
48+
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
49+
[
50+
'@babel/plugin-proposal-nullish-coalescing-operator',
51+
{ loose: false }
52+
],
53+
'@babel/plugin-proposal-do-expressions',
54+
// Stage 2
55+
['@babel/plugin-proposal-decorators', { legacy: true }],
56+
'@babel/plugin-proposal-function-sent',
57+
'@babel/plugin-proposal-export-namespace-from',
58+
'@babel/plugin-proposal-numeric-separator',
59+
'@babel/plugin-proposal-throw-expressions',
60+
// Stage 3
61+
'@babel/plugin-syntax-dynamic-import',
62+
'@babel/plugin-syntax-import-meta',
63+
['@babel/plugin-proposal-class-properties', { loose: false }],
64+
'@babel/plugin-proposal-json-strings'
5065
]
5166
})
5267
],

src/parsers/parse_to_ast.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* @flow */
22

3-
const babylon = require('babylon');
3+
const babelParser = require('@babel/parser');
44

55
const opts = {
66
allowImportExportEverywhere: true,
77
sourceType: 'module',
88
plugins: [
99
'asyncGenerators',
10+
'exportDefaultFrom',
1011
'classConstructorCall',
1112
'classProperties',
1213
'decorators',
@@ -36,5 +37,5 @@ export function commentToFlow(source: string) {
3637
}
3738

3839
export function parseToAst(source: string) {
39-
return babylon.parse(commentToFlow(source), opts);
40+
return babelParser.parse(commentToFlow(source), opts);
4041
}

0 commit comments

Comments
 (0)