From dff93c0cb14bd2c6afa9748e086f96b0b06ff94e Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 9 Jan 2018 09:53:42 -0700 Subject: [PATCH] add experimental babel-plugin-macros support (#3675) * add experimental babel-plugin-macros support closes #2730 This will remain undocumented until the brave have tried it in the wild. **Test Plan:** There's currently no established way to test changes to `babel-preset-react-app`. But I did create [`unmaintained-react-scripts-babel-macros`](https://www.npmjs.com/package/unmaintained-react-scripts-babel-macros) [a while back](https://github.com/facebookincubator/create-react-app/issues/2730#issuecomment-328153982) and it worked well. * Pin the version --- packages/babel-preset-react-app/index.js | 3 +++ packages/babel-preset-react-app/package.json | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 0d961af6f0f..76b20a4637c 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -7,6 +7,9 @@ 'use strict'; const plugins = [ + // Experimental macros support. Will be documented after it's had some time + // in the wild. + require.resolve('babel-plugin-macros'), // class { handleClick = () => { } } require.resolve('babel-plugin-transform-class-properties'), // The following two plugins use Object.assign directly, instead of Babel's diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index f020f99e0b8..d141fca52a0 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -12,6 +12,7 @@ ], "dependencies": { "babel-plugin-dynamic-import-node": "1.1.0", + "babel-plugin-macros": "2.0.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-plugin-transform-class-properties": "6.24.1", "babel-plugin-transform-object-rest-spread": "6.26.0",