Skip to content

Commit ad2d96d

Browse files
committed
Support optional-catch-binding syntax in Babel pipeline
1 parent 068bae7 commit ad2d96d

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lib/babel-pipeline.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function build(projectDir, cacheDir, userOptions, compileEnhancements) {
130130
const ensureStage4 = wantsStage4(userOptions, projectDir);
131131
const containsAsyncGenerators = makeValueChecker('@babel/plugin-syntax-async-generators');
132132
const containsObjectRestSpread = makeValueChecker('@babel/plugin-syntax-object-rest-spread');
133+
const containsOptionalCatchBinding = makeValueChecker('@babel/plugin-syntax-optional-catch-binding');
133134
const containsStage4 = makeValueChecker('../stage-4');
134135
const containsTransformTestFiles = makeValueChecker('@ava/babel-preset-transform-test-files');
135136

@@ -162,6 +163,9 @@ function build(projectDir, cacheDir, userOptions, compileEnhancements) {
162163
if (!testOptions.plugins.some(containsObjectRestSpread)) { // TODO: Remove once Babel can parse this syntax unaided.
163164
testOptions.plugins.unshift(createConfigItem('@babel/plugin-syntax-object-rest-spread', 'plugin'));
164165
}
166+
if (!testOptions.plugins.some(containsOptionalCatchBinding)) { // TODO: Remove once Babel can parse this syntax unaided.
167+
testOptions.plugins.unshift(createConfigItem('@babel/plugin-syntax-optional-catch-binding', 'plugin'));
168+
}
165169
if (ensureStage4 && !testOptions.presets.some(containsStage4)) {
166170
// Apply last.
167171
testOptions.presets.unshift(createConfigItem('../stage-4', 'preset'));

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"@babel/generator": "7.0.0-beta.49",
6666
"@babel/plugin-syntax-async-generators": "7.0.0-beta.49",
6767
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.49",
68+
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.49",
6869
"@concordance/react": "^1.0.0",
6970
"ansi-escapes": "^3.1.0",
7071
"ansi-styles": "^3.2.1",

0 commit comments

Comments
 (0)