Skip to content

Commit 362579a

Browse files
authored
Merge pull request #40 from rwjblue/update-babel-parser
Quick fix for pipelineOperator issue in recast
2 parents 7095e75 + a076a94 commit 362579a

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"test": "qunit tests/**/*-test.js"
1818
},
1919
"dependencies": {
20-
"@babel/parser": "^7.0.0-beta.51",
20+
"@babel/parser": "^7.0.0-beta.53",
2121
"chalk": "^2.4.1",
2222
"common-tags": "^1.8.0",
2323
"execa": "^0.10.0",

src/transform-support.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
function getJSCodeshiftParser(api) {
44
try {
5-
let parser = require('recast/parsers/typescript');
5+
// this is bad, but works around a bug in recent @babel/parser versions:
6+
let babelParser = require('@babel/parser');
7+
let parser = {
8+
parse(source, _options) {
9+
let options = require('recast/parsers/_babylon_options')(_options);
10+
options.plugins = options.plugins.filter(plugin => plugin !== 'pipelineOperator');
11+
options.plugins.push(['pipelineOperator', { proposal: 'minimal' }]);
12+
options.plugins.push('typescript');
13+
14+
return babelParser.parse(source, options);
15+
},
16+
};
17+
18+
// the above should be replace with the following (once
19+
// https://github.com/benjamn/recast/pull/521 lands in a release):
20+
// let parser = require('recast/parsers/typescript');
621

722
return api.jscodeshift.withParser(parser);
823
} catch (e) {

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
js-tokens "^3.0.0"
1818

1919
"@babel/parser@^7.0.0-beta.51":
20-
version "7.0.0-beta.51"
21-
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.0.0-beta.51.tgz#27cec2df409df60af58270ed8f6aa55409ea86f6"
20+
version "7.0.0-beta.53"
21+
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.0.0-beta.53.tgz#1f45eb617bf9463d482b2c04d349d9e4edbf4892"
2222

2323
"@mrmlnc/readdir-enhanced@^2.2.1":
2424
version "2.2.1"

0 commit comments

Comments
 (0)