Skip to content

Commit a076a94

Browse files
author
Robert Jackson
committed
Work around pipelineOperator issue in recast (quick fix).
1 parent 6fec753 commit a076a94

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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) {

0 commit comments

Comments
 (0)