Skip to content

Commit

Permalink
Update babel parser
Browse files Browse the repository at this point in the history
  • Loading branch information
vicapow committed Aug 24, 2018
1 parent 3384c08 commit e31c575
Show file tree
Hide file tree
Showing 7 changed files with 1,213 additions and 757 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"targets": {
"node": 6
},
"include": ["transform-regenerator"]
}],
"flow"
"@babel/preset-flow"
],
"plugins": ["syntax-async-functions"],
"ignore": [
Expand Down
1 change: 1 addition & 0 deletions __tests__/lib/flow_doctrine.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ test('flowDoctrine', function() {
expect(types).toEqual([
'IntersectionTypeAnnotation',
'EmptyTypeAnnotation',
'NumericLiteralTypeAnnotation',
'TypeofTypeAnnotation'
]);
});
38 changes: 28 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,34 @@
"documentation": "./bin/documentation.js"
},
"dependencies": {
"@babel/core": "^7.0.0-rc.3",
"@babel/generator": "^7.0.0-rc.3",
"@babel/parser": "^7.0.0-beta.55",
"@babel/plugin-proposal-class-properties": "^7.0.0-rc.3",
"@babel/plugin-proposal-decorators": "^7.0.0-rc.3",
"@babel/plugin-proposal-do-expressions": "^7.0.0-rc.3",
"@babel/plugin-proposal-export-default-from": "^7.0.0-rc.3",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0-rc.3",
"@babel/plugin-proposal-function-bind": "^7.0.0-rc.3",
"@babel/plugin-proposal-function-sent": "^7.0.0-rc.3",
"@babel/plugin-proposal-json-strings": "^7.0.0-rc.3",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0-rc.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0-rc.3",
"@babel/plugin-proposal-numeric-separator": "^7.0.0-rc.3",
"@babel/plugin-proposal-optional-chaining": "^7.0.0-rc.3",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0-rc.3",
"@babel/plugin-proposal-throw-expressions": "^7.0.0-rc.3",
"@babel/plugin-syntax-dynamic-import": "^7.0.0-rc.3",
"@babel/plugin-syntax-import-meta": "^7.0.0-rc.3",
"@babel/preset-env": "^7.0.0-rc.3",
"@babel/preset-flow": "^7.0.0-rc.3",
"@babel/preset-react": "^7.0.0-rc.3",
"@babel/preset-stage-0": "^7.0.0-rc.3",
"ansi-html": "^0.0.7",
"babel-core": "^6.26.0",
"babel-generator": "^6.26.0",
"babel-plugin-system-import-transformer": "3.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-traverse": "^6.26.0",
"babel-types": "^6.26.0",
"babelify": "^8.0.0",
"babylon": "^6.18.0",
"babelify": "^9.0.0",
"chalk": "^2.3.0",
"chokidar": "^2.0.0",
"concat-stream": "^1.6.0",
Expand Down Expand Up @@ -57,14 +73,16 @@
"vue-template-compiler": "^2.5.16",
"yargs": "^9.0.1"
},
"resolutions": {
"@babel/plugin-syntax-pipeline-operator": "7.0.0-rc.2"
},
"devDependencies": {
"@babel/cli": "^7.0.0-rc.3",
"are-we-flow-yet": "^1.0.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-jest": "^23.0.1",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-preset-flow": "^6.23.0",
"chdir": "0.0.0",
"coveralls": "^3.0.0",
"cz-conventional-changelog": "2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/flow_doctrine.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function flowDoctrine(type: Object): DoctrineType {
type: 'BooleanLiteralType',
value: type.value
};
case 'NumericLiteralTypeAnnotation':
case 'NumberLiteralTypeAnnotation':
return {
type: 'NumericLiteralType',
value: type.value
Expand Down
35 changes: 25 additions & 10 deletions src/input/dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,33 @@ function dependencyStream(
.concat(['.mjs', '.js', '.json', '.es6', '.jsx']),
transform: [
babelify.configure({
sourceMap: false,
sourceMaps: false,
compact: false,
presets: [
require('babel-preset-env'),
require('babel-preset-stage-0'),
require('babel-preset-react')
],
presets: ['@babel/preset-react', '@babel/preset-env'],
plugins: [
require('babel-plugin-transform-decorators-legacy').default,
// Required to support webpack's System.import
// https://github.com/documentationjs/documentation/issues/578
require('babel-plugin-system-import-transformer').default
// Stage 0
'@babel/plugin-proposal-function-bind',
// Stage 1
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-logical-assignment-operators',
['@babel/plugin-proposal-optional-chaining', { loose: false }],
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
[
'@babel/plugin-proposal-nullish-coalescing-operator',
{ loose: false }
],
'@babel/plugin-proposal-do-expressions',
// Stage 2
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
// Stage 3
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['@babel/plugin-proposal-class-properties', { loose: false }],
'@babel/plugin-proposal-json-strings'
]
})
],
Expand Down
5 changes: 3 additions & 2 deletions src/parsers/parse_to_ast.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* @flow */

const babylon = require('babylon');
const babelParser = require('@babel/parser');

const opts = {
allowImportExportEverywhere: true,
sourceType: 'module',
plugins: [
'asyncGenerators',
'exportDefaultFrom',
'classConstructorCall',
'classProperties',
'decorators',
Expand Down Expand Up @@ -36,5 +37,5 @@ export function commentToFlow(source: string) {
}

export function parseToAst(source: string) {
return babylon.parse(commentToFlow(source), opts);
return babelParser.parse(commentToFlow(source), opts);
}
Loading

0 comments on commit e31c575

Please sign in to comment.