next-bun-compile 0.6.11 → 0.6.12

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-8jf4ty06.js";
5
+ } from "./index-7dvf3g60.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { existsSync } from "node:fs";
@@ -167,6 +167,35 @@ function findTurbopackAliases(standaloneNextDir) {
167
167
  subpaths: Array.from(subpaths)
168
168
  }));
169
169
  }
170
+ function rewriteTurbopackAliases(standaloneNextDir, aliases) {
171
+ if (aliases.length === 0)
172
+ return;
173
+ const serverDir = join(standaloneNextDir, "server");
174
+ if (!existsSync(serverDir))
175
+ return;
176
+ const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
177
+ const pattern = new RegExp(`(["'])(` + aliases.map((a) => escape(a.alias)).join("|") + `)(?=[/"'])`, "g");
178
+ const targetByAlias = new Map(aliases.map((a) => [a.alias, a.target]));
179
+ let rewritten = 0;
180
+ for (const f of walkDir(serverDir)) {
181
+ if (!f.absolutePath.endsWith(".js"))
182
+ continue;
183
+ let content;
184
+ try {
185
+ content = readFileSync(f.absolutePath, "utf-8");
186
+ } catch {
187
+ continue;
188
+ }
189
+ const next = content.replace(pattern, (_m, q, alias) => q + targetByAlias.get(alias));
190
+ if (next !== content) {
191
+ writeFileSync(f.absolutePath, next);
192
+ rewritten++;
193
+ }
194
+ }
195
+ if (rewritten > 0) {
196
+ console.log(`next-bun-compile: Rewrote turbopack-mangled aliases in ${rewritten} server chunks`);
197
+ }
198
+ }
170
199
  function findServerDir(standaloneDir) {
171
200
  if (existsSync(join(standaloneDir, "server.js"))) {
172
201
  return standaloneDir;
@@ -328,6 +357,7 @@ function generateEntryPoint(options) {
328
357
  }));
329
358
  const standaloneNextDir = join(serverDir, ".next");
330
359
  const turbopackAliases = findTurbopackAliases(standaloneNextDir);
360
+ rewriteTurbopackAliases(standaloneNextDir, turbopackAliases);
331
361
  const aliasNames = new Set(turbopackAliases.map((a) => a.alias));
332
362
  const runtimeFiles = walkDir(standaloneNextDir).filter((f) => {
333
363
  const m = f.relativePath.replace(/\\/g, "/").match(/^node_modules\/([^/]+)/);
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __require,
3
3
  compile,
4
4
  generateEntryPoint
5
- } from "./index-8jf4ty06.js";
5
+ } from "./index-7dvf3g60.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.6.11",
3
+ "version": "0.6.12",
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",