about summary refs log tree commit diff
path: root/patches/metro-transform-worker+0.76.8.patch
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2023-11-02 18:48:07 +0000
committerGitHub <noreply@github.com>2023-11-02 18:48:07 +0000
commit0e8723c3bb9566542f009994484b30c3da72ede7 (patch)
tree1f3db7484818d63672da264e78e6cda3aa04d149 /patches/metro-transform-worker+0.76.8.patch
parent237bce391b1cf0708df6b137a418725a4029bb6c (diff)
downloadvoidsky-0e8723c3bb9566542f009994484b30c3da72ede7.tar.zst
Patch facebook/metro#1130 to profile module init (#1796)
Diffstat (limited to 'patches/metro-transform-worker+0.76.8.patch')
-rw-r--r--patches/metro-transform-worker+0.76.8.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/patches/metro-transform-worker+0.76.8.patch b/patches/metro-transform-worker+0.76.8.patch
new file mode 100644
index 000000000..d835eee06
--- /dev/null
+++ b/patches/metro-transform-worker+0.76.8.patch
@@ -0,0 +1,41 @@
+diff --git a/node_modules/metro-transform-worker/src/index.js b/node_modules/metro-transform-worker/src/index.js
+index 27d4cb3..fd71f47 100644
+--- a/node_modules/metro-transform-worker/src/index.js
++++ b/node_modules/metro-transform-worker/src/index.js
+@@ -190,6 +190,10 @@ async function transformJS(file, { config, options, projectRoot }) {
+   let dependencyMapName = "";
+   let dependencies;
+   let wrappedAst;
++  const minify =
++    options.minify &&
++    options.unstable_transformProfile !== "hermes-canary" &&
++    options.unstable_transformProfile !== "hermes-stable";
+ 
+   // If the module to transform is a script (meaning that is not part of the
+   // dependency graph and it code will just be prepended to the bundle modules),
+@@ -229,19 +233,20 @@ async function transformJS(file, { config, options, projectRoot }) {
+     if (config.unstable_disableModuleWrapping === true) {
+       wrappedAst = ast;
+     } else {
++      let moduleFactoryName;
++      if (options.dev && !minify) {
++        moduleFactoryName = file.filename;
++      }
+       ({ ast: wrappedAst } = JsFileWrapping.wrapModule(
+         ast,
+         importDefault,
+         importAll,
+         dependencyMapName,
+-        config.globalPrefix
++        config.globalPrefix,
++        moduleFactoryName
+       ));
+     }
+   }
+-  const minify =
+-    options.minify &&
+-    options.unstable_transformProfile !== "hermes-canary" &&
+-    options.unstable_transformProfile !== "hermes-stable";
+   const reserved = [];
+   if (config.unstable_dependencyMapReservedName != null) {
+     reserved.push(config.unstable_dependencyMapReservedName);