Use preset-react's development option + enable modules transform in test env (#5081)
## Minor changes
When `NODE_ENV=test` is used we'll now apply the `'auto'` configuration for modules transformation. Which causes Babel to check if the current environment needs to be transformed or not. In practice this means that the following `.babelrc` is not needed anymore:
**OLD**:
```json
{
"env": {
"development": {
"presets": ["next/babel"]
},
"production": {
"presets": ["next/babel"]
},
"test": {
"presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
}
}
}
```
**NEW**:
```
{
"presets": ["next/babel"]
}
```
## Patches
`@babel/preset-react` has a `development` option that automatically applies a development-time plugin we manually applied before (`@babel/plugin-transform-react-jsx-source`). It also adds another development-time plugin that is said to make debugging/errors clearer: `@babel/plugin-transform-react-jsx-self` which we didn't apply before. Overall this means we can take advantage of preset-react to provide these plugins.
Showing
| ... | @@ -66,7 +66,6 @@ | ... | @@ -66,7 +66,6 @@ |
| "@babel/plugin-proposal-class-properties": "7.0.0", | "@babel/plugin-proposal-class-properties": "7.0.0", | ||
| "@babel/plugin-proposal-object-rest-spread": "7.0.0", | "@babel/plugin-proposal-object-rest-spread": "7.0.0", | ||
| "@babel/plugin-syntax-dynamic-import": "7.0.0", | "@babel/plugin-syntax-dynamic-import": "7.0.0", | ||
| "@babel/plugin-transform-react-jsx-source": "7.0.0", | |||
| "@babel/plugin-transform-runtime": "7.0.0", | "@babel/plugin-transform-runtime": "7.0.0", | ||
| "@babel/preset-env": "7.0.0", | "@babel/preset-env": "7.0.0", | ||
| "@babel/preset-react": "7.0.0", | "@babel/preset-react": "7.0.0", | ||
| ... | ... |
Please
register
or
sign in
to comment