Skip to content

Commit 4b7ca52

Browse files
committed
📌 Exclude the new ReactNative preset from production builds
In #1193, I added `module:@react-native/babel-preset` That caused the unit tests to work, but caused a WSOD with the release build e-mission/e-mission-docs#1113 (comment) So we exclude the preset for production builds I tried to add it only to dev builds, but the `process.env.ENV` is not set correctly so I had to switch the condition e-mission/e-mission-docs#1113 (comment) Testing done: ``` $ npm run test Test Suites: 27 passed, 27 total Tests: 182 passed, 182 total Snapshots: 0 total Time: 10.537 s Ran all test suites. ```
1 parent 32ca5fd commit 4b7ca52

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

babel.config.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
module.exports = {
2-
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react', 'module:@react-native/babel-preset'],
3-
plugins: ['@babel/plugin-transform-flow-strip-types'],
1+
module.exports = function(api) {
2+
api.cache(true);
3+
const presets = ['@babel/preset-env',
4+
'@babel/preset-typescript',
5+
'@babel/preset-react'];
6+
const plugins = ['@babel/plugin-transform-flow-strip-types'];
7+
8+
if (process.env.ENV !== "production") {
9+
presets.push('module:@react-native/babel-preset');
10+
}
11+
console.log("Running in environment "+process.env.ENV);
12+
13+
return {presets, plugins};
414
}

0 commit comments

Comments
 (0)