next-bun-compile 0.6.3 → 0.6.5

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-dxk9rwqh.js";
5
+ } from "./index-mcq5wghd.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { existsSync } from "node:fs";
@@ -112,24 +112,46 @@ function generateStubs(standaloneDir) {
112
112
  }
113
113
  }
114
114
  function findTurbopackAliases(standaloneNextDir) {
115
+ const seen = new Map;
116
+ const serverDir = join(standaloneNextDir, "server");
117
+ if (existsSync(serverDir)) {
118
+ const re = /require\(["']([^"'\s/]+-[0-9a-f]{16})["']\)/g;
119
+ for (const f of walkDir(serverDir)) {
120
+ if (!f.absolutePath.endsWith(".js"))
121
+ continue;
122
+ let content;
123
+ try {
124
+ content = readFileSync(f.absolutePath, "utf-8");
125
+ } catch {
126
+ continue;
127
+ }
128
+ let m;
129
+ while (m = re.exec(content)) {
130
+ const alias = m[1];
131
+ if (seen.has(alias))
132
+ continue;
133
+ seen.set(alias, alias.replace(/-[0-9a-f]{16}$/, ""));
134
+ }
135
+ }
136
+ }
115
137
  const nodeModulesDir = join(standaloneNextDir, "node_modules");
116
- if (!existsSync(nodeModulesDir))
117
- return [];
118
- const aliases = [];
119
- for (const entry of readdirSync(nodeModulesDir)) {
120
- if (!/-[0-9a-f]{16}$/.test(entry))
121
- continue;
122
- const aliasPath = join(nodeModulesDir, entry);
123
- try {
124
- if (!lstatSync(aliasPath).isSymbolicLink())
138
+ if (existsSync(nodeModulesDir)) {
139
+ for (const entry of readdirSync(nodeModulesDir)) {
140
+ if (!/-[0-9a-f]{16}$/.test(entry))
125
141
  continue;
126
- const target = basename(realpathSync(aliasPath));
127
- aliases.push({ alias: entry, target });
128
- } catch {
129
- continue;
142
+ if (seen.has(entry))
143
+ continue;
144
+ const aliasPath = join(nodeModulesDir, entry);
145
+ try {
146
+ if (!lstatSync(aliasPath).isSymbolicLink())
147
+ continue;
148
+ seen.set(entry, basename(realpathSync(aliasPath)));
149
+ } catch {
150
+ continue;
151
+ }
130
152
  }
131
153
  }
132
- return aliases;
154
+ return Array.from(seen, ([alias, target]) => ({ alias, target }));
133
155
  }
134
156
  function findServerDir(standaloneDir) {
135
157
  if (existsSync(join(standaloneDir, "server.js"))) {
@@ -387,20 +409,15 @@ async function extractAssets() {
387
409
  for (const [alias, target] of turbopackAliases) {
388
410
  const aliasPath = path.join(baseDir, ".next/node_modules", alias);
389
411
  if (fs.existsSync(aliasPath)) continue;
390
- fs.mkdirSync(path.dirname(aliasPath), { recursive: true });
391
- try {
392
- fs.symlinkSync(target, aliasPath, "dir");
393
- } catch {
394
- fs.mkdirSync(aliasPath, { recursive: true });
395
- fs.writeFileSync(
396
- path.join(aliasPath, "package.json"),
397
- JSON.stringify({ name: alias, main: "index.js" })
398
- );
399
- fs.writeFileSync(
400
- path.join(aliasPath, "index.js"),
401
- "module.exports = require(" + JSON.stringify(target) + ");"
402
- );
403
- }
412
+ fs.mkdirSync(aliasPath, { recursive: true });
413
+ fs.writeFileSync(
414
+ path.join(aliasPath, "package.json"),
415
+ JSON.stringify({ name: alias, main: "index.js" })
416
+ );
417
+ fs.writeFileSync(
418
+ path.join(aliasPath, "index.js"),
419
+ "module.exports = require(" + JSON.stringify(target) + ");"
420
+ );
404
421
  }
405
422
  if (n > 0) console.log(\`Extracted \${n} assets\`);
406
423
  }
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __require,
3
3
  compile,
4
4
  generateEntryPoint
5
- } from "./index-dxk9rwqh.js";
5
+ } from "./index-mcq5wghd.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.3",
3
+ "version": "0.6.5",
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",