next-bun-compile 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  compile,
4
4
  generateEntryPoint
5
- } from "./index-np1qb2b3.js";
5
+ } from "./index-jevfyh6f.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { existsSync } from "node:fs";
@@ -753,13 +753,25 @@ if (Number.isNaN(keepAliveTimeout) || !Number.isFinite(keepAliveTimeout) || keep
753
753
 
754
754
  const extractions = ${JSON.stringify(assetExtractions)};
755
755
  async function extractAssets() {
756
- let n = 0;
756
+ // Collect everything that isn't already on disk, dedupe parent dirs
757
+ // for a single mkdir pass, then issue all writes concurrently.
758
+ // ~45% faster than serial extraction on a typical Next.js app with
759
+ // sharp; trivially correct because each write is to a distinct path.
760
+ const todo = [];
757
761
  for (const [urlPath, diskPath] of extractions) {
758
762
  const fullPath = path.join(baseDir, diskPath);
759
763
  if (fs.existsSync(fullPath)) continue;
760
- fs.mkdirSync(path.dirname(fullPath), { recursive: true });
761
764
  const embedded = assetMap.get(urlPath);
762
765
  if (!embedded) continue;
766
+ todo.push({ diskPath, fullPath, embedded });
767
+ }
768
+ if (todo.length === 0) return;
769
+
770
+ const dirs = new Set();
771
+ for (const t of todo) dirs.add(path.dirname(t.fullPath));
772
+ for (const d of dirs) fs.mkdirSync(d, { recursive: true });
773
+
774
+ await Promise.all(todo.map(async ({ diskPath, fullPath, embedded }) => {
763
775
  // Server chunks may contain __NBC_BASE__ placeholders injected at
764
776
  // build time by rewriteTurbopackAliases. Substitute the real baseDir
765
777
  // before writing so bun resolves the absolute paths at chunk load
@@ -768,14 +780,12 @@ async function extractAssets() {
768
780
  const text = await Bun.file(embedded).text();
769
781
  if (text.indexOf("__NBC_BASE__") !== -1) {
770
782
  await Bun.write(fullPath, text.split("__NBC_BASE__").join(baseDir));
771
- n++;
772
- continue;
783
+ return;
773
784
  }
774
785
  }
775
786
  await Bun.write(fullPath, Bun.file(embedded));
776
- n++;
777
- }
778
- if (n > 0) console.log(\`Extracted \${n} assets\`);
787
+ }));
788
+ console.log(\`Extracted \${todo.length} assets\`);
779
789
  }
780
790
 
781
791
  extractAssets().then(() => {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __require,
3
3
  compile,
4
4
  generateEntryPoint
5
- } from "./index-np1qb2b3.js";
5
+ } from "./index-jevfyh6f.js";
6
6
 
7
7
  // src/index.ts
8
8
  import { join } from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-bun-compile",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Next.js Build Adapter that compiles your app into a Bun single-file executable",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",