next-bun-compile 0.6.9 → 0.6.10
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 +1 -1
- package/dist/{index-h8ak29p2.js → index-rx8tn52q.js} +92 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -494,11 +494,103 @@ ${mapEntries.join(`
|
|
|
494
494
|
const serverEntry = `import { assetMap } from "./assets.generated.js";
|
|
495
495
|
const path = require("path");
|
|
496
496
|
const fs = require("fs");
|
|
497
|
+
const Module = require("module");
|
|
497
498
|
|
|
498
499
|
const baseDir = path.dirname(process.execPath);
|
|
499
500
|
process.chdir(baseDir);
|
|
500
501
|
process.env.NODE_ENV = "production";
|
|
501
502
|
|
|
503
|
+
// Install a fallback Module._resolveFilename hook. bun's compiled-binary
|
|
504
|
+
// resolver doesn't walk node_modules from inside a node_modules entry, so
|
|
505
|
+
// once execution enters an extracted package (sharp/lib/index.js → require
|
|
506
|
+
// of detect-libc, @img/sharp-linux-x64/sharp.node, etc.) bun gives up. This
|
|
507
|
+
// hook runs ONLY when bun's resolver throws and reimplements Node-compatible
|
|
508
|
+
// resolution from scratch — walk node_modules, read package.json main,
|
|
509
|
+
// honor exports maps. Generic: every externalized package's internal deps
|
|
510
|
+
// get resolved without per-package patching.
|
|
511
|
+
const __nbcOrigResolveFilename = Module._resolveFilename;
|
|
512
|
+
function __nbcStatFile(p) {
|
|
513
|
+
try { return fs.statSync(p).isFile() ? p : null; } catch { return null; }
|
|
514
|
+
}
|
|
515
|
+
function __nbcResolveMain(pkgDir, pkgJson) {
|
|
516
|
+
const main = pkgJson && typeof pkgJson.main === "string" ? pkgJson.main : "index.js";
|
|
517
|
+
return __nbcStatFile(path.join(pkgDir, main))
|
|
518
|
+
|| __nbcStatFile(path.join(pkgDir, main + ".js"))
|
|
519
|
+
|| __nbcStatFile(path.join(pkgDir, main + ".cjs"))
|
|
520
|
+
|| __nbcStatFile(path.join(pkgDir, main + ".mjs"))
|
|
521
|
+
|| __nbcStatFile(path.join(pkgDir, main, "index.js"))
|
|
522
|
+
|| __nbcStatFile(path.join(pkgDir, "index.js"))
|
|
523
|
+
|| __nbcStatFile(path.join(pkgDir, "index.cjs"));
|
|
524
|
+
}
|
|
525
|
+
function __nbcResolveSubpath(pkgDir, pkgJson, sub) {
|
|
526
|
+
// Honor exports map (CJS-relevant conditions only)
|
|
527
|
+
if (pkgJson && pkgJson.exports && typeof pkgJson.exports === "object") {
|
|
528
|
+
const key = "./" + sub;
|
|
529
|
+
const entry = pkgJson.exports[key];
|
|
530
|
+
if (entry) {
|
|
531
|
+
let target = typeof entry === "string"
|
|
532
|
+
? entry
|
|
533
|
+
: entry.require || entry.node || entry.default;
|
|
534
|
+
if (typeof target === "string" && target.startsWith("./")) {
|
|
535
|
+
const f = __nbcStatFile(path.join(pkgDir, target.slice(2)));
|
|
536
|
+
if (f) return f;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return __nbcStatFile(path.join(pkgDir, sub))
|
|
541
|
+
|| __nbcStatFile(path.join(pkgDir, sub + ".js"))
|
|
542
|
+
|| __nbcStatFile(path.join(pkgDir, sub + ".cjs"))
|
|
543
|
+
|| __nbcStatFile(path.join(pkgDir, sub + ".mjs"))
|
|
544
|
+
|| __nbcStatFile(path.join(pkgDir, sub + ".json"))
|
|
545
|
+
|| __nbcStatFile(path.join(pkgDir, sub, "index.js"))
|
|
546
|
+
|| __nbcStatFile(path.join(pkgDir, sub, "index.cjs"));
|
|
547
|
+
}
|
|
548
|
+
function __nbcResolvePackage(request, fromDir) {
|
|
549
|
+
let pkgName, sub = "";
|
|
550
|
+
if (request[0] === "@") {
|
|
551
|
+
const m = request.match(/^(@[^/]+\\/[^/]+)(?:\\/(.+))?$/);
|
|
552
|
+
if (!m) return null;
|
|
553
|
+
pkgName = m[1]; sub = m[2] || "";
|
|
554
|
+
} else {
|
|
555
|
+
const idx = request.indexOf("/");
|
|
556
|
+
if (idx === -1) { pkgName = request; }
|
|
557
|
+
else { pkgName = request.slice(0, idx); sub = request.slice(idx + 1); }
|
|
558
|
+
}
|
|
559
|
+
let dir = fromDir;
|
|
560
|
+
while (dir.length > 1) {
|
|
561
|
+
const pkgDir = path.join(dir, "node_modules", pkgName);
|
|
562
|
+
if (fs.existsSync(pkgDir)) {
|
|
563
|
+
let pkgJson = null;
|
|
564
|
+
const pkgJsonPath = path.join(pkgDir, "package.json");
|
|
565
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
566
|
+
try { pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")); } catch {}
|
|
567
|
+
}
|
|
568
|
+
const resolved = sub
|
|
569
|
+
? __nbcResolveSubpath(pkgDir, pkgJson, sub)
|
|
570
|
+
: __nbcResolveMain(pkgDir, pkgJson);
|
|
571
|
+
if (resolved) return resolved;
|
|
572
|
+
}
|
|
573
|
+
const parent = path.dirname(dir);
|
|
574
|
+
if (parent === dir) break;
|
|
575
|
+
dir = parent;
|
|
576
|
+
}
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
Module._resolveFilename = function(request, parent, isMain, options) {
|
|
580
|
+
try {
|
|
581
|
+
return __nbcOrigResolveFilename.call(this, request, parent, isMain, options);
|
|
582
|
+
} catch (err) {
|
|
583
|
+
// Only attempt fallback for bare package specifiers
|
|
584
|
+
if (typeof request !== "string" || request[0] === "." || request[0] === "/" || /^[a-z]+:/.test(request)) {
|
|
585
|
+
throw err;
|
|
586
|
+
}
|
|
587
|
+
const fromDir = parent && parent.filename ? path.dirname(parent.filename) : process.cwd();
|
|
588
|
+
const resolved = __nbcResolvePackage(request, fromDir);
|
|
589
|
+
if (resolved) return resolved;
|
|
590
|
+
throw err;
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
502
594
|
const nextConfig = ${configMatch[1]};
|
|
503
595
|
process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(nextConfig);
|
|
504
596
|
|
package/dist/index.js
CHANGED