drapanjanas/re-natal

RN 0.57 breaks with advanced compilation

vikeri opened this issue · 2 comments

I had some trouble with RN 0.57.5, got the following error: Can't find variable a.

After looking around I solved it by patching the metro bundler in node_modules:

metro/src/JSTransformer/worker.js

--- worker.js	2018-11-21 14:46:01.271844624 -0700
+++ worker.js	2018-11-21 14:45:52.517615272 -0700
@@ -199,10 +199,10 @@
         plugins.push([inlineRequiresPlugin, opts]);
       }
 
-      if (!options.dev) {
-        plugins.push([constantFoldingPlugin, opts]);
-        plugins.push([inlinePlugin, opts]);
-      }
+      // if (!options.dev) {
+      // plugins.push([constantFoldingPlugin, opts]);
+      plugins.push([inlinePlugin, opts]);
+      // }
       var _transformFromAstSync = transformFromAstSync(ast, "", {
         ast: true,
         babelrc: false,

Apply the code above with patch node_modules/metro/src/JSTransformer/worker.js ./<savethesnippetabove>.patch

Tracking the upstream issue here: facebook/metro#317

Note that constant folding only breaks the file produced by advanced compilation. You only need to tell the worker to avoid that particular file.

More detail in the issue on metro I reported a few weeks ago facebook/metro#291