Skip to content

Commit

Permalink
Support optional-catch-binding syntax in Babel pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed May 31, 2018
1 parent 068bae7 commit ad2d96d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/babel-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function build(projectDir, cacheDir, userOptions, compileEnhancements) {
const ensureStage4 = wantsStage4(userOptions, projectDir);
const containsAsyncGenerators = makeValueChecker('@babel/plugin-syntax-async-generators');
const containsObjectRestSpread = makeValueChecker('@babel/plugin-syntax-object-rest-spread');
const containsOptionalCatchBinding = makeValueChecker('@babel/plugin-syntax-optional-catch-binding');
const containsStage4 = makeValueChecker('../stage-4');
const containsTransformTestFiles = makeValueChecker('@ava/babel-preset-transform-test-files');

Expand Down Expand Up @@ -162,6 +163,9 @@ function build(projectDir, cacheDir, userOptions, compileEnhancements) {
if (!testOptions.plugins.some(containsObjectRestSpread)) { // TODO: Remove once Babel can parse this syntax unaided.
testOptions.plugins.unshift(createConfigItem('@babel/plugin-syntax-object-rest-spread', 'plugin'));
}
if (!testOptions.plugins.some(containsOptionalCatchBinding)) { // TODO: Remove once Babel can parse this syntax unaided.
testOptions.plugins.unshift(createConfigItem('@babel/plugin-syntax-optional-catch-binding', 'plugin'));
}
if (ensureStage4 && !testOptions.presets.some(containsStage4)) {
// Apply last.
testOptions.presets.unshift(createConfigItem('../stage-4', 'preset'));
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@babel/generator": "7.0.0-beta.49",
"@babel/plugin-syntax-async-generators": "7.0.0-beta.49",
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.49",
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.49",
"@concordance/react": "^1.0.0",
"ansi-escapes": "^3.1.0",
"ansi-styles": "^3.2.1",
Expand Down

0 comments on commit ad2d96d

Please sign in to comment.