@absolutejs/absolute 0.19.0-beta.950 → 0.19.0-beta.952
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/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +39 -15
- package/dist/angular/index.js.map +5 -5
- package/dist/angular/server.js +39 -15
- package/dist/angular/server.js.map +5 -5
- package/dist/build.js +1235 -717
- package/dist/build.js.map +21 -19
- package/dist/cli/index.js +159 -92
- package/dist/index.js +1359 -815
- package/dist/index.js.map +28 -26
- package/dist/islands/index.js +5 -5
- package/dist/islands/index.js.map +3 -3
- package/dist/react/components/browser/index.js +17 -2
- package/dist/react/components/index.js +19 -3
- package/dist/react/components/index.js.map +5 -4
- package/dist/react/index.js +37 -13
- package/dist/react/index.js.map +4 -4
- package/dist/react/server.js +33 -9
- package/dist/react/server.js.map +3 -3
- package/dist/src/build/chainInlineSourcemaps.d.ts +13 -0
- package/dist/src/build/externalAssetPlugin.d.ts +2 -0
- package/dist/src/core/devRouteRegistrationCallsite.d.ts +1 -0
- package/dist/src/core/prepare.d.ts +11 -2
- package/dist/src/dev/clientManager.d.ts +1 -0
- package/dist/src/dev/serverEntryWatcher.d.ts +1 -0
- package/dist/src/react/components/Head.d.ts +1 -1
- package/dist/src/utils/generateHeadElement.d.ts +1 -1
- package/dist/src/utils/jsonLd.d.ts +1 -0
- package/dist/svelte/index.js +37 -13
- package/dist/svelte/index.js.map +4 -4
- package/dist/svelte/server.js +37 -13
- package/dist/svelte/server.js.map +4 -4
- package/dist/types/globals.d.ts +1 -4
- package/dist/types/metadata.d.ts +2 -0
- package/dist/vue/index.js +37 -13
- package/dist/vue/index.js.map +5 -5
- package/dist/vue/server.js +33 -9
- package/dist/vue/server.js.map +4 -4
- package/package.json +17 -1
package/dist/cli/index.js
CHANGED
|
@@ -1277,6 +1277,45 @@ var init_build = __esm(() => {
|
|
|
1277
1277
|
init_telemetryEvent();
|
|
1278
1278
|
});
|
|
1279
1279
|
|
|
1280
|
+
// src/build/externalAssetPlugin.ts
|
|
1281
|
+
import { copyFileSync, existsSync as existsSync10, mkdirSync as mkdirSync6, statSync } from "fs";
|
|
1282
|
+
import { basename as basename2, dirname as dirname3, join as join9, resolve as resolve10 } from "path";
|
|
1283
|
+
var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
1284
|
+
name: "absolute-external-asset",
|
|
1285
|
+
setup(bld) {
|
|
1286
|
+
const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
|
|
1287
|
+
const skipRoots = userSourceRoots.map((root) => resolve10(root));
|
|
1288
|
+
const isUserSource = (path) => skipRoots.some((root) => path.startsWith(`${root}/`));
|
|
1289
|
+
bld.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async (args) => {
|
|
1290
|
+
if (isUserSource(args.path))
|
|
1291
|
+
return;
|
|
1292
|
+
const source = await Bun.file(args.path).text();
|
|
1293
|
+
if (!source.includes("import.meta.url"))
|
|
1294
|
+
return;
|
|
1295
|
+
urlPattern.lastIndex = 0;
|
|
1296
|
+
let match;
|
|
1297
|
+
const sourceDir = dirname3(args.path);
|
|
1298
|
+
while ((match = urlPattern.exec(source)) !== null) {
|
|
1299
|
+
const relPath = match[1];
|
|
1300
|
+
if (!relPath)
|
|
1301
|
+
continue;
|
|
1302
|
+
const assetPath = resolve10(sourceDir, relPath);
|
|
1303
|
+
if (!existsSync10(assetPath))
|
|
1304
|
+
continue;
|
|
1305
|
+
if (!statSync(assetPath).isFile())
|
|
1306
|
+
continue;
|
|
1307
|
+
const targetPath = join9(outDir, basename2(assetPath));
|
|
1308
|
+
if (existsSync10(targetPath))
|
|
1309
|
+
continue;
|
|
1310
|
+
mkdirSync6(dirname3(targetPath), { recursive: true });
|
|
1311
|
+
copyFileSync(assetPath, targetPath);
|
|
1312
|
+
}
|
|
1313
|
+
return;
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
var init_externalAssetPlugin = () => {};
|
|
1318
|
+
|
|
1280
1319
|
// src/cli/scripts/compile.ts
|
|
1281
1320
|
var exports_compile = {};
|
|
1282
1321
|
__export(exports_compile, {
|
|
@@ -1286,16 +1325,16 @@ __export(exports_compile, {
|
|
|
1286
1325
|
var {env: env3 } = globalThis.Bun;
|
|
1287
1326
|
import {
|
|
1288
1327
|
cpSync,
|
|
1289
|
-
existsSync as
|
|
1290
|
-
mkdirSync as
|
|
1328
|
+
existsSync as existsSync11,
|
|
1329
|
+
mkdirSync as mkdirSync7,
|
|
1291
1330
|
readdirSync as readdirSync2,
|
|
1292
1331
|
readFileSync as readFileSync12,
|
|
1293
1332
|
rmSync as rmSync4,
|
|
1294
|
-
statSync,
|
|
1333
|
+
statSync as statSync2,
|
|
1295
1334
|
unlinkSync as unlinkSync3,
|
|
1296
1335
|
writeFileSync as writeFileSync4
|
|
1297
1336
|
} from "fs";
|
|
1298
|
-
import { basename as
|
|
1337
|
+
import { basename as basename3, dirname as dirname4, join as join10, relative, resolve as resolve11 } from "path";
|
|
1299
1338
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
1300
1339
|
const resolvedVersion = version2 || "unknown";
|
|
1301
1340
|
console.log("");
|
|
@@ -1308,7 +1347,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1308
1347
|
const entry = pending.pop();
|
|
1309
1348
|
if (!entry)
|
|
1310
1349
|
continue;
|
|
1311
|
-
const fullPath =
|
|
1350
|
+
const fullPath = join10(entry.parentPath, entry.name);
|
|
1312
1351
|
if (entry.isDirectory())
|
|
1313
1352
|
pending = pending.concat(readdirSync2(fullPath, { withFileTypes: true }));
|
|
1314
1353
|
else
|
|
@@ -1328,7 +1367,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1328
1367
|
const entry = pending.pop();
|
|
1329
1368
|
if (!entry)
|
|
1330
1369
|
continue;
|
|
1331
|
-
const fullPath =
|
|
1370
|
+
const fullPath = join10(entry.parentPath, entry.name);
|
|
1332
1371
|
if (entry.isDirectory()) {
|
|
1333
1372
|
if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
|
|
1334
1373
|
continue;
|
|
@@ -1340,18 +1379,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1340
1379
|
return result;
|
|
1341
1380
|
}, copyServerRuntimeAssetReferences = (outdir) => {
|
|
1342
1381
|
const copied = new Set;
|
|
1343
|
-
const normalizedOutdir =
|
|
1382
|
+
const normalizedOutdir = resolve11(outdir);
|
|
1344
1383
|
const copyReference = (filePath, relPath) => {
|
|
1345
|
-
const assetSource =
|
|
1346
|
-
if (!
|
|
1384
|
+
const assetSource = resolve11(dirname4(filePath), relPath);
|
|
1385
|
+
if (!existsSync11(assetSource) || !statSync2(assetSource).isFile())
|
|
1347
1386
|
return;
|
|
1348
|
-
const assetTarget =
|
|
1387
|
+
const assetTarget = resolve11(normalizedOutdir, relPath.replace(/^\.\//, ""));
|
|
1349
1388
|
if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
|
|
1350
1389
|
return;
|
|
1351
1390
|
if (copied.has(assetTarget))
|
|
1352
1391
|
return;
|
|
1353
1392
|
copied.add(assetTarget);
|
|
1354
|
-
|
|
1393
|
+
mkdirSync7(dirname4(assetTarget), { recursive: true });
|
|
1355
1394
|
cpSync(assetSource, assetTarget, { force: true });
|
|
1356
1395
|
};
|
|
1357
1396
|
for (const filePath of collectProjectSourceFiles(process.cwd())) {
|
|
@@ -1419,18 +1458,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1419
1458
|
return resolveBuildModule3(remaining);
|
|
1420
1459
|
}, resolveJsxDevRuntimeCompatPath2 = () => {
|
|
1421
1460
|
const candidates = [
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1461
|
+
resolve11(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
1462
|
+
resolve11(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
1463
|
+
resolve11(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
|
|
1464
|
+
resolve11(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
1465
|
+
resolve11(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
1466
|
+
resolve11(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
1428
1467
|
];
|
|
1429
1468
|
for (const candidate of candidates) {
|
|
1430
|
-
if (
|
|
1469
|
+
if (existsSync11(candidate))
|
|
1431
1470
|
return candidate;
|
|
1432
1471
|
}
|
|
1433
|
-
return
|
|
1472
|
+
return resolve11(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
1434
1473
|
}, jsxDevRuntimeCompatPath2, shouldEmbedCompiledAsset = (relativePath, skip = new Set) => {
|
|
1435
1474
|
if (skip.has(relativePath))
|
|
1436
1475
|
return false;
|
|
@@ -1443,11 +1482,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1443
1482
|
return true;
|
|
1444
1483
|
}, tryReadNodePackageJson = (packageDir) => {
|
|
1445
1484
|
try {
|
|
1446
|
-
return JSON.parse(readFileSync12(
|
|
1485
|
+
return JSON.parse(readFileSync12(join10(packageDir, "package.json"), "utf-8"));
|
|
1447
1486
|
} catch {
|
|
1448
1487
|
return null;
|
|
1449
1488
|
}
|
|
1450
|
-
}, resolveProjectPackageDir = (specifier) =>
|
|
1489
|
+
}, resolveProjectPackageDir = (specifier) => resolve11(process.cwd(), "node_modules", ...specifier.split("/")), copyPackageToBuild = (specifier, outdir, seen) => {
|
|
1451
1490
|
if (seen.has(specifier))
|
|
1452
1491
|
return;
|
|
1453
1492
|
const srcDir = resolveProjectPackageDir(specifier);
|
|
@@ -1455,7 +1494,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1455
1494
|
if (!pkg)
|
|
1456
1495
|
return;
|
|
1457
1496
|
seen.add(specifier);
|
|
1458
|
-
const destDir =
|
|
1497
|
+
const destDir = join10(outdir, "node_modules", ...specifier.split("/"));
|
|
1459
1498
|
rmSync4(destDir, { force: true, recursive: true });
|
|
1460
1499
|
cpSync(srcDir, destDir, {
|
|
1461
1500
|
filter(source) {
|
|
@@ -1477,8 +1516,8 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1477
1516
|
}, copyAngularRuntimePackages = (buildConfig, outdir) => {
|
|
1478
1517
|
if (!buildConfig.angularDirectory)
|
|
1479
1518
|
return;
|
|
1480
|
-
const angularScopeDir =
|
|
1481
|
-
const angularPackages =
|
|
1519
|
+
const angularScopeDir = resolve11(process.cwd(), "node_modules", "@angular");
|
|
1520
|
+
const angularPackages = existsSync11(angularScopeDir) ? readdirSync2(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
|
|
1482
1521
|
const roots = new Set([
|
|
1483
1522
|
...angularPackages,
|
|
1484
1523
|
"rxjs",
|
|
@@ -1501,15 +1540,15 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1501
1540
|
}
|
|
1502
1541
|
copyAngularRuntimePackages(buildConfig, outdir);
|
|
1503
1542
|
}, collectRuntimePackageSpecifiers = (distDir) => {
|
|
1504
|
-
const nodeModulesDir =
|
|
1505
|
-
if (!
|
|
1543
|
+
const nodeModulesDir = join10(distDir, "node_modules");
|
|
1544
|
+
if (!existsSync11(nodeModulesDir))
|
|
1506
1545
|
return [];
|
|
1507
1546
|
const specifiers = [];
|
|
1508
1547
|
for (const entry of readdirSync2(nodeModulesDir, { withFileTypes: true })) {
|
|
1509
1548
|
if (!entry.isDirectory())
|
|
1510
1549
|
continue;
|
|
1511
1550
|
if (entry.name.startsWith("@")) {
|
|
1512
|
-
const scopeDir =
|
|
1551
|
+
const scopeDir = join10(nodeModulesDir, entry.name);
|
|
1513
1552
|
for (const scopedEntry of readdirSync2(scopeDir, {
|
|
1514
1553
|
withFileTypes: true
|
|
1515
1554
|
})) {
|
|
@@ -1523,7 +1562,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1523
1562
|
}
|
|
1524
1563
|
return specifiers.sort((a, b) => b.length - a.length);
|
|
1525
1564
|
}, ensureRelativeModuleSpecifier = (fromFile, toFile) => {
|
|
1526
|
-
const rel = relative(
|
|
1565
|
+
const rel = relative(dirname4(fromFile), toFile).replace(/\\/g, "/");
|
|
1527
1566
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
1528
1567
|
}, pickExportEntry = (value) => {
|
|
1529
1568
|
if (typeof value === "string")
|
|
@@ -1541,21 +1580,21 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1541
1580
|
const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
|
|
1542
1581
|
if (!packageSpecifier)
|
|
1543
1582
|
return null;
|
|
1544
|
-
const packageDir =
|
|
1583
|
+
const packageDir = join10(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
1545
1584
|
const subpath = specifier.slice(packageSpecifier.length);
|
|
1546
|
-
const subPackageDir = subpath ?
|
|
1547
|
-
const resolvedPackageDir = subPackageDir &&
|
|
1548
|
-
const packageJsonPath =
|
|
1549
|
-
if (!
|
|
1585
|
+
const subPackageDir = subpath ? join10(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
1586
|
+
const resolvedPackageDir = subPackageDir && existsSync11(join10(subPackageDir, "package.json")) ? subPackageDir : packageDir;
|
|
1587
|
+
const packageJsonPath = join10(resolvedPackageDir, "package.json");
|
|
1588
|
+
if (!existsSync11(packageJsonPath))
|
|
1550
1589
|
return null;
|
|
1551
1590
|
const pkg = JSON.parse(readFileSync12(packageJsonPath, "utf-8"));
|
|
1552
1591
|
const exportKey = resolvedPackageDir === subPackageDir ? "." : subpath ? `.${subpath}` : ".";
|
|
1553
1592
|
const rootExport = pkg.exports?.[exportKey];
|
|
1554
1593
|
const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
1555
|
-
return
|
|
1594
|
+
return join10(resolvedPackageDir, entry);
|
|
1556
1595
|
}, RUNTIME_JS_EXTENSIONS, MODULE_SPECIFIER_RE, isRuntimeJsFile = (filePath) => RUNTIME_JS_EXTENSIONS.some((extension) => filePath.endsWith(extension)), isNodeModulesPath = (filePath) => filePath.split(/[\\/]/).includes("node_modules"), isFile = (filePath) => {
|
|
1557
1596
|
try {
|
|
1558
|
-
return
|
|
1597
|
+
return statSync2(filePath).isFile();
|
|
1559
1598
|
} catch {
|
|
1560
1599
|
return false;
|
|
1561
1600
|
}
|
|
@@ -1565,16 +1604,16 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1565
1604
|
const candidates = [
|
|
1566
1605
|
candidate,
|
|
1567
1606
|
...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
|
|
1568
|
-
...RUNTIME_JS_EXTENSIONS.map((extension) =>
|
|
1607
|
+
...RUNTIME_JS_EXTENSIONS.map((extension) => join10(candidate, `index${extension}`))
|
|
1569
1608
|
];
|
|
1570
1609
|
return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
|
|
1571
1610
|
}, findContainingRuntimePackageDir = (filePath) => {
|
|
1572
|
-
let dir =
|
|
1573
|
-
while (dir !==
|
|
1574
|
-
if (isNodeModulesPath(dir) &&
|
|
1611
|
+
let dir = dirname4(filePath);
|
|
1612
|
+
while (dir !== dirname4(dir)) {
|
|
1613
|
+
if (isNodeModulesPath(dir) && existsSync11(join10(dir, "package.json"))) {
|
|
1575
1614
|
return dir;
|
|
1576
1615
|
}
|
|
1577
|
-
dir =
|
|
1616
|
+
dir = dirname4(dir);
|
|
1578
1617
|
}
|
|
1579
1618
|
return null;
|
|
1580
1619
|
}, resolvePackageImportEntryFile = (fromFile, specifier) => {
|
|
@@ -1587,7 +1626,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1587
1626
|
const entry = pickExportEntry(pkg?.imports?.[specifier]);
|
|
1588
1627
|
if (!entry)
|
|
1589
1628
|
return null;
|
|
1590
|
-
return
|
|
1629
|
+
return join10(packageDir, entry);
|
|
1591
1630
|
}, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), rewriteRuntimeModuleSpecifiers = (distDir) => {
|
|
1592
1631
|
const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
|
|
1593
1632
|
if (packageSpecifiers.length === 0)
|
|
@@ -1609,7 +1648,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1609
1648
|
const source = readFileSync12(filePath, "utf-8");
|
|
1610
1649
|
const rewritten = source.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
|
|
1611
1650
|
if (typeof specifier === "string" && specifier.startsWith(".")) {
|
|
1612
|
-
enqueue(resolveRuntimeJsFile(
|
|
1651
|
+
enqueue(resolveRuntimeJsFile(resolve11(dirname4(filePath), specifier)));
|
|
1613
1652
|
return match;
|
|
1614
1653
|
}
|
|
1615
1654
|
const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
|
|
@@ -1629,7 +1668,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1629
1668
|
}
|
|
1630
1669
|
}, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2, buildConfig) => {
|
|
1631
1670
|
const allFiles = collectFiles2(distDir);
|
|
1632
|
-
const serverBundleName = `${
|
|
1671
|
+
const serverBundleName = `${basename3(serverEntry).replace(/\.[^.]+$/, "")}.js`;
|
|
1633
1672
|
const embeddedSkip = new Set(["_compile_entrypoint.ts"]);
|
|
1634
1673
|
const assetSkip = new Set([
|
|
1635
1674
|
serverBundleName,
|
|
@@ -1694,7 +1733,7 @@ import { pathToFileURL } from "node:url";
|
|
|
1694
1733
|
const SERVER_MODULE = (runtimeDir: string) => import(pathToFileURL(join(runtimeDir, ${JSON.stringify(serverBundleName)})).href);
|
|
1695
1734
|
const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
|
|
1696
1735
|
const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
|
|
1697
|
-
const ORIGINAL_BUILD_DIR = ${JSON.stringify(
|
|
1736
|
+
const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve11(distDir))};
|
|
1698
1737
|
const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
|
|
1699
1738
|
|
|
1700
1739
|
// \u2500\u2500 Asset URL \u2192 embedded path map \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -1737,6 +1776,19 @@ const getMime = (p: string) =>
|
|
|
1737
1776
|
// \u2500\u2500 Server \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1738
1777
|
const port = Number(process.env.PORT) || ${DEFAULT_PORT};
|
|
1739
1778
|
|
|
1779
|
+
// Uncaught-error safety net for the compiled binary. \`bun --hot\` and
|
|
1780
|
+
// \`bun dev\` both keep the process alive on uncaught throws / rejections;
|
|
1781
|
+
// a standalone executable has no such wrapper, so a stream-error inside
|
|
1782
|
+
// a route handler (\`controller.error(new Error(...))\`) would otherwise
|
|
1783
|
+
// kill the server. Log loudly + stay up \u2014 same shape as the resilience
|
|
1784
|
+
// every production HTTP server is expected to have.
|
|
1785
|
+
process.on("uncaughtException", (err) => {
|
|
1786
|
+
console.error("[absolutejs] uncaught exception:", err);
|
|
1787
|
+
});
|
|
1788
|
+
process.on("unhandledRejection", (reason) => {
|
|
1789
|
+
console.error("[absolutejs] unhandled rejection:", reason);
|
|
1790
|
+
});
|
|
1791
|
+
|
|
1740
1792
|
const servePage = (path: string) =>
|
|
1741
1793
|
new Response(Bun.file(path), {
|
|
1742
1794
|
headers: { "content-type": "text/html; charset=utf-8" },
|
|
@@ -1941,8 +1993,11 @@ console.log(\`
|
|
|
1941
1993
|
loader: "js"
|
|
1942
1994
|
}));
|
|
1943
1995
|
bld.onLoad({
|
|
1944
|
-
filter: /dev\/(assetStore|clientManager|webSocket|moduleVersionTracker|buildHMRClient)\.ts$/
|
|
1945
|
-
}, () => ({
|
|
1996
|
+
filter: /dev\/(assetStore|clientManager|webSocket|moduleVersionTracker|buildHMRClient|serverEntryWatcher)\.ts$/
|
|
1997
|
+
}, () => ({
|
|
1998
|
+
contents: "export const startServerEntryWatcher = () => {}; export const isAtomicWriteTemp = () => false;",
|
|
1999
|
+
loader: "js"
|
|
2000
|
+
}));
|
|
1946
2001
|
bld.onLoad({ filter: /dev\/moduleServer\.(ts|js)$/ }, () => ({
|
|
1947
2002
|
contents: "export {};",
|
|
1948
2003
|
loader: "js"
|
|
@@ -1991,16 +2046,16 @@ console.log(\`
|
|
|
1991
2046
|
return false;
|
|
1992
2047
|
return true;
|
|
1993
2048
|
}), compile = async (serverEntry, outdir, outfile, configPath2) => {
|
|
1994
|
-
const resolvedOutdir =
|
|
2049
|
+
const resolvedOutdir = resolve11(outdir ?? "dist");
|
|
1995
2050
|
await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath2));
|
|
1996
2051
|
}, compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath2) => {
|
|
1997
2052
|
const prerenderPort = Number(env3.COMPILE_PORT) || Number(env3.PORT) || DEFAULT_PORT + 1;
|
|
1998
2053
|
killStaleProcesses(prerenderPort);
|
|
1999
|
-
const entryName =
|
|
2000
|
-
const resolvedOutfile =
|
|
2054
|
+
const entryName = basename3(serverEntry).replace(/\.[^.]+$/, "");
|
|
2055
|
+
const resolvedOutfile = resolve11(outfile ?? "compiled-server");
|
|
2001
2056
|
const absoluteVersion = resolvePackageVersion3([
|
|
2002
|
-
|
|
2003
|
-
|
|
2057
|
+
resolve11(import.meta.dir, "..", "..", "..", "package.json"),
|
|
2058
|
+
resolve11(import.meta.dir, "..", "..", "package.json")
|
|
2004
2059
|
]);
|
|
2005
2060
|
compileBanner(absoluteVersion);
|
|
2006
2061
|
const totalStart = performance.now();
|
|
@@ -2011,8 +2066,8 @@ console.log(\`
|
|
|
2011
2066
|
buildConfig.mode = "production";
|
|
2012
2067
|
try {
|
|
2013
2068
|
const build2 = await resolveBuildModule3([
|
|
2014
|
-
|
|
2015
|
-
|
|
2069
|
+
resolve11(import.meta.dir, "..", "..", "core", "build"),
|
|
2070
|
+
resolve11(import.meta.dir, "..", "build")
|
|
2016
2071
|
]);
|
|
2017
2072
|
if (!build2)
|
|
2018
2073
|
throw new Error("Could not locate build module");
|
|
@@ -2025,9 +2080,17 @@ console.log(\`
|
|
|
2025
2080
|
console.log(` \x1B[2m(${getDurationString(performance.now() - buildStart)})\x1B[0m`);
|
|
2026
2081
|
const bundleStart = performance.now();
|
|
2027
2082
|
process.stdout.write(cliTag4("\x1B[36m", "Bundling production server"));
|
|
2083
|
+
const userSourceRoots = [
|
|
2084
|
+
buildConfig.reactDirectory,
|
|
2085
|
+
buildConfig.svelteDirectory,
|
|
2086
|
+
buildConfig.vueDirectory,
|
|
2087
|
+
buildConfig.angularDirectory,
|
|
2088
|
+
buildConfig.htmlDirectory,
|
|
2089
|
+
buildConfig.htmxDirectory
|
|
2090
|
+
].filter((dir) => Boolean(dir));
|
|
2028
2091
|
const serverBundle = await Bun.build({
|
|
2029
2092
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
2030
|
-
entrypoints: [
|
|
2093
|
+
entrypoints: [resolve11(serverEntry)],
|
|
2031
2094
|
external: resolveServerBundleExternals(buildConfig),
|
|
2032
2095
|
outdir: resolvedOutdir,
|
|
2033
2096
|
plugins: [
|
|
@@ -2036,22 +2099,24 @@ console.log(\`
|
|
|
2036
2099
|
stubReact: !buildConfig.reactDirectory,
|
|
2037
2100
|
stubSvelte: !buildConfig.svelteDirectory,
|
|
2038
2101
|
stubVue: !buildConfig.vueDirectory
|
|
2039
|
-
})
|
|
2102
|
+
}),
|
|
2103
|
+
createExternalAssetPlugin(resolvedOutdir, userSourceRoots)
|
|
2040
2104
|
],
|
|
2041
|
-
target: "bun"
|
|
2105
|
+
target: "bun",
|
|
2106
|
+
throw: false
|
|
2042
2107
|
});
|
|
2043
2108
|
if (!serverBundle.success) {
|
|
2044
2109
|
serverBundle.logs.forEach((log) => console.error(log));
|
|
2045
2110
|
console.error(cliTag4("\x1B[31m", "Server bundle failed."));
|
|
2046
2111
|
process.exit(1);
|
|
2047
2112
|
}
|
|
2048
|
-
const outputPath =
|
|
2049
|
-
if (!
|
|
2113
|
+
const outputPath = resolve11(resolvedOutdir, `${entryName}.js`);
|
|
2114
|
+
if (!existsSync11(outputPath)) {
|
|
2050
2115
|
console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
2051
2116
|
process.exit(1);
|
|
2052
2117
|
}
|
|
2053
|
-
if (
|
|
2054
|
-
const vendorDir =
|
|
2118
|
+
if (existsSync11(resolve11(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
2119
|
+
const vendorDir = resolve11(resolvedOutdir, "angular", "vendor", "server");
|
|
2055
2120
|
const vendorEntries = readdirSync2(vendorDir).filter((f) => f.endsWith(".js"));
|
|
2056
2121
|
const angularServerVendorPaths = {};
|
|
2057
2122
|
for (const file of vendorEntries) {
|
|
@@ -2060,7 +2125,7 @@ console.log(\`
|
|
|
2060
2125
|
if (scope !== "angular" || rest.length === 0)
|
|
2061
2126
|
continue;
|
|
2062
2127
|
const specifier = `@angular/${rest.join("/")}`;
|
|
2063
|
-
const relPath = relative(
|
|
2128
|
+
const relPath = relative(dirname4(outputPath), resolve11(vendorDir, file));
|
|
2064
2129
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
2065
2130
|
}
|
|
2066
2131
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -2072,7 +2137,7 @@ console.log(\`
|
|
|
2072
2137
|
copyServerRuntimeAssetReferences(resolvedOutdir);
|
|
2073
2138
|
const prerenderStart = performance.now();
|
|
2074
2139
|
process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
|
|
2075
|
-
rmSync4(
|
|
2140
|
+
rmSync4(join10(resolvedOutdir, "_prerendered"), {
|
|
2076
2141
|
force: true,
|
|
2077
2142
|
recursive: true
|
|
2078
2143
|
});
|
|
@@ -2091,9 +2156,9 @@ console.log(\`
|
|
|
2091
2156
|
const compileStart = performance.now();
|
|
2092
2157
|
process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
|
|
2093
2158
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
|
2094
|
-
const entrypointPath =
|
|
2159
|
+
const entrypointPath = join10(resolvedOutdir, "_compile_entrypoint.ts");
|
|
2095
2160
|
await Bun.write(entrypointPath, entrypointCode);
|
|
2096
|
-
|
|
2161
|
+
mkdirSync7(dirname4(resolvedOutfile), { recursive: true });
|
|
2097
2162
|
const result = await Bun.build({
|
|
2098
2163
|
compile: { outfile: resolvedOutfile },
|
|
2099
2164
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
@@ -2121,7 +2186,7 @@ console.log(\`
|
|
|
2121
2186
|
const size = (Bun.file(resolvedOutfile).size / BYTES_PER_MB).toFixed(0);
|
|
2122
2187
|
const totalDuration = getDurationString(performance.now() - totalStart);
|
|
2123
2188
|
console.log(cliTag4("\x1B[32m", `Compiled to ${resolvedOutfile} (${size}MB) in ${totalDuration}`));
|
|
2124
|
-
console.log(cliTag4("\x1B[2m", `Run with: ./${
|
|
2189
|
+
console.log(cliTag4("\x1B[2m", `Run with: ./${basename3(resolvedOutfile)}`));
|
|
2125
2190
|
sendTelemetryEvent("compile:complete", {
|
|
2126
2191
|
durationMs: Math.round(performance.now() - totalStart),
|
|
2127
2192
|
entry: serverEntry,
|
|
@@ -2129,6 +2194,7 @@ console.log(\`
|
|
|
2129
2194
|
});
|
|
2130
2195
|
};
|
|
2131
2196
|
var init_compile = __esm(() => {
|
|
2197
|
+
init_externalAssetPlugin();
|
|
2132
2198
|
init_constants();
|
|
2133
2199
|
init_prerender();
|
|
2134
2200
|
init_getDurationString();
|
|
@@ -2184,8 +2250,8 @@ var exports_typecheck = {};
|
|
|
2184
2250
|
__export(exports_typecheck, {
|
|
2185
2251
|
typecheck: () => typecheck
|
|
2186
2252
|
});
|
|
2187
|
-
import { resolve as
|
|
2188
|
-
import { existsSync as
|
|
2253
|
+
import { resolve as resolve12, join as join11 } from "path";
|
|
2254
|
+
import { existsSync as existsSync12, readFileSync as readFileSync13 } from "fs";
|
|
2189
2255
|
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
2190
2256
|
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), getTypecheckTargets = async (configPath2) => {
|
|
2191
2257
|
const rawConfig = await loadRawConfig(configPath2);
|
|
@@ -2205,8 +2271,8 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
|
|
|
2205
2271
|
const exitCode = await proc.exited;
|
|
2206
2272
|
return { exitCode, name, output: (stdout + stderr).trim() };
|
|
2207
2273
|
}, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
|
|
2208
|
-
const local =
|
|
2209
|
-
return
|
|
2274
|
+
const local = resolve12("node_modules", ".bin", name);
|
|
2275
|
+
return existsSync12(local) ? local : null;
|
|
2210
2276
|
}, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi3 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
|
|
2211
2277
|
const cwd = `${process.cwd()}/`;
|
|
2212
2278
|
const summaryMatch = stripAnsi3(output).match(/svelte-check found (\d+) error/);
|
|
@@ -2253,15 +2319,15 @@ Found ${errorCount} error${suffix}.`;
|
|
|
2253
2319
|
return formatted;
|
|
2254
2320
|
}, ABSOLUTE_INTERNAL_EXCLUDES, resolveAbsoluteTypeFile = (fileName) => {
|
|
2255
2321
|
const candidates = [
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2322
|
+
resolve12("node_modules/@absolutejs/absolute/dist/types", fileName),
|
|
2323
|
+
resolve12(import.meta.dir, "../types", fileName),
|
|
2324
|
+
resolve12(import.meta.dir, "../../types", fileName),
|
|
2325
|
+
resolve12(import.meta.dir, "../../../types", fileName)
|
|
2260
2326
|
];
|
|
2261
|
-
return candidates.find((candidate) =>
|
|
2327
|
+
return candidates.find((candidate) => existsSync12(candidate)) ?? candidates[0];
|
|
2262
2328
|
}, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
|
|
2263
2329
|
try {
|
|
2264
|
-
return JSON.parse(readFileSync13(
|
|
2330
|
+
return JSON.parse(readFileSync13(resolve12("tsconfig.json"), "utf-8"));
|
|
2265
2331
|
} catch {
|
|
2266
2332
|
return {};
|
|
2267
2333
|
}
|
|
@@ -2289,22 +2355,22 @@ Found ${errorCount} error${suffix}.`;
|
|
|
2289
2355
|
console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
|
|
2290
2356
|
process.exit(1);
|
|
2291
2357
|
}
|
|
2292
|
-
const vueTsconfigPath =
|
|
2358
|
+
const vueTsconfigPath = join11(cacheDir, "tsconfig.vue-check.json");
|
|
2293
2359
|
return writeFile(vueTsconfigPath, JSON.stringify({
|
|
2294
2360
|
compilerOptions: {
|
|
2295
2361
|
rootDir: ".."
|
|
2296
2362
|
},
|
|
2297
2363
|
exclude: getProjectTypecheckExcludes(),
|
|
2298
|
-
extends:
|
|
2364
|
+
extends: resolve12("tsconfig.json"),
|
|
2299
2365
|
include: getProjectTypecheckIncludes()
|
|
2300
2366
|
}, null, "\t")).then(() => run("vue-tsc", [
|
|
2301
2367
|
vueTscBin,
|
|
2302
2368
|
"--noEmit",
|
|
2303
2369
|
"--project",
|
|
2304
|
-
|
|
2370
|
+
resolve12(vueTsconfigPath),
|
|
2305
2371
|
"--incremental",
|
|
2306
2372
|
"--tsBuildInfoFile",
|
|
2307
|
-
|
|
2373
|
+
join11(cacheDir, "vue-tsc.tsbuildinfo"),
|
|
2308
2374
|
"--pretty"
|
|
2309
2375
|
]));
|
|
2310
2376
|
}, buildAngularCheck = async (cacheDir, angularDir) => {
|
|
@@ -2313,7 +2379,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
2313
2379
|
console.error("\x1B[31m\u2717\x1B[0m @angular/compiler-cli is required for Angular type checking. Install it: bun add -d @angular/compiler-cli");
|
|
2314
2380
|
process.exit(1);
|
|
2315
2381
|
}
|
|
2316
|
-
const angularTsconfigPath =
|
|
2382
|
+
const angularTsconfigPath = join11(cacheDir, "tsconfig.angular-check.json");
|
|
2317
2383
|
await writeFile(angularTsconfigPath, JSON.stringify({
|
|
2318
2384
|
angularCompilerOptions: {
|
|
2319
2385
|
strictTemplates: true
|
|
@@ -2323,32 +2389,32 @@ Found ${errorCount} error${suffix}.`;
|
|
|
2323
2389
|
rootDir: ".."
|
|
2324
2390
|
},
|
|
2325
2391
|
exclude: ABSOLUTE_INTERNAL_EXCLUDES.map(toGeneratedConfigPath),
|
|
2326
|
-
extends:
|
|
2392
|
+
extends: resolve12("tsconfig.json"),
|
|
2327
2393
|
include: [`../${angularDir}/**/*`]
|
|
2328
2394
|
}, null, "\t"));
|
|
2329
|
-
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(
|
|
2395
|
+
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve12(angularTsconfigPath))}`);
|
|
2330
2396
|
}, buildTscCheck = (cacheDir) => {
|
|
2331
2397
|
const tscBin = findBin("tsc");
|
|
2332
2398
|
if (!tscBin) {
|
|
2333
2399
|
console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
|
|
2334
2400
|
process.exit(1);
|
|
2335
2401
|
}
|
|
2336
|
-
const tscConfigPath =
|
|
2402
|
+
const tscConfigPath = join11(cacheDir, "tsconfig.typecheck.json");
|
|
2337
2403
|
return writeFile(tscConfigPath, JSON.stringify({
|
|
2338
2404
|
compilerOptions: {
|
|
2339
2405
|
rootDir: ".."
|
|
2340
2406
|
},
|
|
2341
2407
|
exclude: getProjectTypecheckExcludes(),
|
|
2342
|
-
extends:
|
|
2408
|
+
extends: resolve12("tsconfig.json"),
|
|
2343
2409
|
include: getProjectTypecheckIncludes()
|
|
2344
2410
|
}, null, "\t")).then(() => run("tsc", [
|
|
2345
2411
|
tscBin,
|
|
2346
2412
|
"--noEmit",
|
|
2347
2413
|
"--project",
|
|
2348
|
-
|
|
2414
|
+
resolve12(tscConfigPath),
|
|
2349
2415
|
"--incremental",
|
|
2350
2416
|
"--tsBuildInfoFile",
|
|
2351
|
-
|
|
2417
|
+
join11(cacheDir, "tsc.tsbuildinfo"),
|
|
2352
2418
|
"--pretty"
|
|
2353
2419
|
]));
|
|
2354
2420
|
}, buildSvelteCheck = async (cacheDir, svelteDir) => {
|
|
@@ -2357,16 +2423,16 @@ Found ${errorCount} error${suffix}.`;
|
|
|
2357
2423
|
console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
|
|
2358
2424
|
process.exit(1);
|
|
2359
2425
|
}
|
|
2360
|
-
const svelteTsconfigPath =
|
|
2426
|
+
const svelteTsconfigPath = join11(cacheDir, "tsconfig.svelte-check.json");
|
|
2361
2427
|
await writeFile(svelteTsconfigPath, JSON.stringify({
|
|
2362
|
-
extends:
|
|
2428
|
+
extends: resolve12("tsconfig.json"),
|
|
2363
2429
|
files: ABSOLUTE_TYPECHECK_FILES,
|
|
2364
2430
|
include: [`../${svelteDir}/**/*`]
|
|
2365
2431
|
}, null, "\t"));
|
|
2366
2432
|
return run("svelte-check", [
|
|
2367
2433
|
svelteBin,
|
|
2368
2434
|
"--tsconfig",
|
|
2369
|
-
|
|
2435
|
+
resolve12(svelteTsconfigPath),
|
|
2370
2436
|
"--threshold",
|
|
2371
2437
|
"error",
|
|
2372
2438
|
"--compiler-warnings",
|
|
@@ -4004,9 +4070,9 @@ var start = async (serverEntry, outdir, configPath2) => {
|
|
|
4004
4070
|
loader: "js"
|
|
4005
4071
|
}));
|
|
4006
4072
|
bld.onLoad({
|
|
4007
|
-
filter: /dev\/(assetStore|clientManager|webSocket|moduleVersionTracker|buildHMRClient)\.ts$/
|
|
4073
|
+
filter: /dev\/(assetStore|clientManager|webSocket|moduleVersionTracker|buildHMRClient|serverEntryWatcher)\.ts$/
|
|
4008
4074
|
}, () => ({
|
|
4009
|
-
contents: "export {};",
|
|
4075
|
+
contents: "export const startServerEntryWatcher = () => {}; export const isAtomicWriteTemp = () => false;",
|
|
4010
4076
|
loader: "js"
|
|
4011
4077
|
}));
|
|
4012
4078
|
bld.onLoad({ filter: /cli\/(telemetryEvent|scripts\/telemetry)\.ts$/ }, () => ({
|
|
@@ -4068,7 +4134,8 @@ var start = async (serverEntry, outdir, configPath2) => {
|
|
|
4068
4134
|
],
|
|
4069
4135
|
outdir: resolvedOutdir,
|
|
4070
4136
|
plugins: [stubPlugin],
|
|
4071
|
-
target: "bun"
|
|
4137
|
+
target: "bun",
|
|
4138
|
+
throw: false
|
|
4072
4139
|
});
|
|
4073
4140
|
if (!serverBundle.success) {
|
|
4074
4141
|
handleBundleFailure(serverBundle, bundleStart, serverEntry);
|