about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--babel.config.js6
-rw-r--r--metro.config.js10
2 files changed, 16 insertions, 0 deletions
diff --git a/babel.config.js b/babel.config.js
index a38edf1d6..0baec0c3c 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,11 +1,17 @@
 module.exports = function (api) {
   api.cache(true)
+  const isTestEnv = process.env.NODE_ENV === 'test'
   return {
     presets: [
       [
         'babel-preset-expo',
         {
           lazyImports: true,
+          native: {
+            // Disable ESM -> CJS compilation because Metro takes care of it.
+            // However, we need it in Jest tests since those run without Metro.
+            disableImportExportTransform: !isTestEnv,
+          },
         },
       ],
     ],
diff --git a/metro.config.js b/metro.config.js
index 08527fced..a49d95f9a 100644
--- a/metro.config.js
+++ b/metro.config.js
@@ -8,7 +8,17 @@ cfg.resolver.sourceExts = process.env.RN_SRC_EXT
 
 cfg.transformer.getTransformOptions = async () => ({
   transform: {
+    experimentalImportSupport: true,
     inlineRequires: true,
+    nonInlinedRequires: [
+      // We can remove this option and rely on the default after
+      // https://github.com/facebook/metro/pull/1126 is released.
+      'React',
+      'react',
+      'react/jsx-dev-runtime',
+      'react/jsx-runtime',
+      'react-native',
+    ],
   },
 })