Skip to content

Commit

Permalink
feat(gatsby): support ?. and ?? in generated pages (#20036)
Browse files Browse the repository at this point in the history
* feat(gatsby): support `?.` and `??` in generated pages

Basically tested with an empty repo in dev mode, added `console.log(SEO?.foo ?? 'bar')` before and after this change. Before it would crash on the new syntax and afterwards it would work. Both `develop` and `build`.

* update README.md to include newly added babel plugins
  • Loading branch information
pvdz authored and GatsbyJS Bot committed Dec 10, 2019
1 parent 5692266 commit ea6185c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/babel-preset-gatsby/README.md
Expand Up @@ -13,6 +13,8 @@ For more information on how to customize the Babel configuration of your Gatsby
- [`@babel/plugin-transform-runtime`](https://babeljs.io/docs/en/babel-plugin-transform-runtime#docsNav)
- [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros)
- [`babel-plugin-transform-react-remove-prop-types`](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types)
- [`@babel/plugin-proposal-nullish-coalescing-operator`](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator)
- [`@babel/plugin-proposal-optional-chaining`](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining)

## Usage

Expand Down
2 changes: 2 additions & 0 deletions packages/babel-preset-gatsby/package.json
Expand Up @@ -10,6 +10,8 @@
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/babel-preset-gatsby#readme",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4",
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/plugin-transform-spread": "^7.7.4",
Expand Down
Expand Up @@ -9,6 +9,12 @@ Object {
"loose": true,
},
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
],
"<PROJECT_ROOT>/node_modules/babel-plugin-macros/dist/index.js",
"<PROJECT_ROOT>/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
Expand Down Expand Up @@ -66,6 +72,12 @@ Object {
"loose": true,
},
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
],
"<PROJECT_ROOT>/node_modules/babel-plugin-macros/dist/index.js",
"<PROJECT_ROOT>/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
Expand Down Expand Up @@ -127,6 +139,12 @@ Object {
"loose": true,
},
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
],
"<PROJECT_ROOT>/node_modules/babel-plugin-macros/dist/index.js",
"<PROJECT_ROOT>/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
Expand Down Expand Up @@ -182,6 +200,12 @@ Object {
"loose": true,
},
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
],
Array [
"<PROJECT_ROOT>/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
],
"<PROJECT_ROOT>/node_modules/babel-plugin-macros/dist/index.js",
"<PROJECT_ROOT>/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-preset-gatsby/src/index.js
Expand Up @@ -76,6 +76,8 @@ module.exports = function preset(_, options = {}) {
loose: true,
},
],
[resolve(`@babel/plugin-proposal-nullish-coalescing-operator`)],
[resolve(`@babel/plugin-proposal-optional-chaining`)],
resolve(`babel-plugin-macros`),
resolve(`@babel/plugin-syntax-dynamic-import`),
[
Expand Down

0 comments on commit ea6185c

Please sign in to comment.