Skip to content

Commit cbde4c1

Browse files
authored
fix(metro-serializer-esbuild): don't block on metafile write (#3842)
1 parent cf94fcc commit cbde4c1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.changeset/moody-terms-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rnx-kit/metro-serializer-esbuild": patch
3+
---
4+
5+
Don't block when writing metafile

packages/metro-serializer-esbuild/src/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,23 @@ export function MetroSerializer(
323323
esbuild
324324
.analyzeMetafile(metafile, options)
325325
.then((text) => info(text));
326+
} else {
327+
info("esbuild bundle size:", result.code.length);
326328
}
329+
327330
if (typeof buildOptions?.metafile === "string") {
328-
fs.writeFileSync(
329-
path.join(path.dirname(sourcemapfile), buildOptions.metafile),
330-
typeof metafile === "string" ? metafile : JSON.stringify(metafile)
331-
);
332-
info("esbuild bundle size:", result.code.length);
331+
const outDir = path.dirname(sourcemapfile);
332+
const out = path.join(outDir, buildOptions.metafile);
333+
334+
info("Writing esbuild metafile to:", out);
335+
336+
const metadata =
337+
typeof metafile === "string"
338+
? metafile
339+
: JSON.stringify(metafile);
340+
fs.writeFile(out, metadata, () => {
341+
info("Done writing esbuild metafile");
342+
});
333343
}
334344
} else {
335345
info("esbuild bundle size:", result.code.length);

0 commit comments

Comments
 (0)