@absolutejs/absolute 0.20.0-beta.155 → 0.20.0-beta.157

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.
@@ -1,7 +1,9 @@
1
1
  // @bun
2
2
  import {
3
- maskLiterals
4
- } from "./index-039rh39e.js";
3
+ maskLiterals,
4
+ compileSpecifierRewriter,
5
+ rewriteContentSpecifiers
6
+ } from "./index-bp60baze.js";
5
7
  import {
6
8
  loadIslandRegistryBuildInfo
7
9
  } from "./index-e6ysp900.js";
@@ -61,14 +63,191 @@ import {
61
63
  // src/cli/scripts/compile.ts
62
64
  var {env } = globalThis.Bun;
63
65
 
66
+ // src/build/compiledClientGraph.ts
67
+ import { createHash } from "crypto";
68
+ import ts from "typescript";
69
+ import {
70
+ existsSync,
71
+ readdirSync,
72
+ readFileSync,
73
+ mkdirSync,
74
+ writeFileSync
75
+ } from "fs";
76
+ import { dirname, isAbsolute, join, relative, resolve } from "path";
77
+ var assetUrlEdit = (node, tree, urls) => {
78
+ if (!ts.isNewExpression(node) || !ts.isIdentifier(node.expression) || node.expression.text !== "URL")
79
+ return;
80
+ const [path, base] = node.arguments ?? [];
81
+ if (!path || !ts.isStringLiteral(path) || base?.getText(tree) !== "import.meta.url" || !urls[path.text])
82
+ return;
83
+ const edit = {
84
+ end: path.end,
85
+ start: path.getStart(tree),
86
+ value: JSON.stringify(urls[path.text])
87
+ };
88
+ return edit;
89
+ };
90
+ var rewriteAssetUrlConstructors = (source, urls) => {
91
+ if (!/\bnew\s+URL\s*\(/u.test(source))
92
+ return source;
93
+ const tree = ts.createSourceFile("client.js", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
94
+ const edits = [];
95
+ const visit = (node) => {
96
+ const edit = assetUrlEdit(node, tree, urls);
97
+ if (edit)
98
+ edits.push(edit);
99
+ ts.forEachChild(node, visit);
100
+ };
101
+ visit(tree);
102
+ return edits.sort((left, right) => right.start - left.start).reduce((text, edit) => text.slice(0, edit.start) + edit.value + text.slice(edit.end), source);
103
+ };
104
+ var referencedAsset = (node, tree, file, directory) => {
105
+ if (!ts.isNewExpression(node) || !ts.isIdentifier(node.expression) || node.expression.text !== "URL")
106
+ return;
107
+ const [path, base] = node.arguments ?? [];
108
+ if (!path || !ts.isStringLiteral(path) || base?.getText(tree) !== "import.meta.url")
109
+ return;
110
+ return path.text.startsWith("/") ? resolve(directory, path.text.slice(1)) : resolve(dirname(file), path.text);
111
+ };
112
+ var includeUrlDependencies = (files, directory, allowed) => {
113
+ const included = new Set(files);
114
+ for (let index = 0;index < files.length; index++) {
115
+ const file = files[index];
116
+ if (!file || !/\.m?js$/.test(file))
117
+ continue;
118
+ const source = readFileSync(file, "utf8");
119
+ if (!/\bnew\s+URL\s*\(/u.test(source))
120
+ continue;
121
+ const tree = ts.createSourceFile("client.js", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
122
+ const visit = (node) => {
123
+ const target = referencedAsset(node, tree, file, directory);
124
+ if (target && allowed.has(target) && !included.has(target)) {
125
+ included.add(target);
126
+ files.push(target);
127
+ }
128
+ ts.forEachChild(node, visit);
129
+ };
130
+ visit(tree);
131
+ }
132
+ return files;
133
+ };
134
+ var CLIENT_GRAPH_PREFIX = "/_absolute/assets/";
135
+ var isClientGraphAsset = (path) => {
136
+ const parts = path.split("/");
137
+ if (parts.some((part) => part.startsWith(".") || [
138
+ "server",
139
+ "node_modules",
140
+ "_absolute",
141
+ "_prerendered"
142
+ ].includes(part)))
143
+ return false;
144
+ if (/^(?:react|vue|svelte|angular|ember)\/pages\//.test(path))
145
+ return false;
146
+ return /\.(?:js|mjs|css|wasm|woff2?|ttf|otf|png|jpe?g|svg|gif|webp|avif|ico)$/.test(path);
147
+ };
148
+ var filesIn = (root) => readdirSync(root, { withFileTypes: true }).flatMap((entry) => {
149
+ const path = join(root, entry.name);
150
+ if (entry.isDirectory())
151
+ return filesIn(path);
152
+ if (entry.isFile())
153
+ return [path];
154
+ return [];
155
+ });
156
+ var readBuildManifest = (directory) => {
157
+ const path = join(directory, "manifest.json");
158
+ const manifest = existsSync(path) ? JSON.parse(readFileSync(path, "utf8")) : {};
159
+ if (!manifest || typeof manifest !== "object" || Array.isArray(manifest))
160
+ throw new Error("Invalid build manifest");
161
+ return manifest;
162
+ };
163
+ var withinDirectory = (directory, path) => {
164
+ const rel = relative(directory, path);
165
+ return rel !== "" && !isAbsolute(rel) && rel.split(/[\\/]/u)[0] !== "..";
166
+ };
167
+ var localServerDependencies = (file, directory, scanner) => {
168
+ if (!existsSync(file) || !/\.m?js$/.test(file))
169
+ return [];
170
+ return scanner.scanImports(readFileSync(file, "utf8")).filter((dependency) => dependency.path.startsWith(".")).map((dependency) => resolve(dirname(file), dependency.path)).filter((path) => withinDirectory(directory, path));
171
+ };
172
+ var collectServerGraph = (directory, manifest) => {
173
+ const serverFiles = new Set(Object.values(manifest).filter((value) => typeof value === "string" && withinDirectory(directory, value)));
174
+ const pending = [...serverFiles];
175
+ const scanner = new Bun.Transpiler({ loader: "js" });
176
+ for (let index = 0;index < pending.length; index++) {
177
+ const file = pending[index];
178
+ if (!file)
179
+ continue;
180
+ const children = localServerDependencies(file, directory, scanner).filter((path) => !serverFiles.has(path));
181
+ children.forEach((path) => serverFiles.add(path));
182
+ pending.push(...children);
183
+ }
184
+ return serverFiles;
185
+ };
186
+ var rewriteCssUrls = (source, urls) => source.replace(/url\(\s*(["']?)(\/[^\s)'"?#]+)([^)'"\s]*)\1\s*\)/g, (match, quote, path, suffix) => urls[path] ? `url(${quote}${urls[path]}${suffix}${quote})` : match);
187
+ var rewriteGraphAsset = (file, rewriter, urls) => {
188
+ const bytes = readFileSync(file);
189
+ if (/\.m?js$/.test(file))
190
+ return rewriteAssetUrlConstructors(rewriteContentSpecifiers(bytes.toString(), rewriter, {
191
+ sweep: true
192
+ }), urls);
193
+ if (file.endsWith(".css"))
194
+ return rewriteCssUrls(bytes.toString(), urls);
195
+ return bytes;
196
+ };
197
+ var rewriteManifest = (directory, urls) => {
198
+ const path = join(directory, "manifest.json");
199
+ if (!existsSync(path))
200
+ return;
201
+ const manifest = readBuildManifest(directory);
202
+ for (const [key, value] of Object.entries(manifest)) {
203
+ if (typeof value !== "string" || !urls[value])
204
+ continue;
205
+ Reflect.set(manifest, key, urls[value]);
206
+ }
207
+ writeFileSync(path, JSON.stringify(manifest, null, "\t"));
208
+ };
209
+ var prepareCompiledClientGraph = (directory, serverBundle, publicDirectory) => {
210
+ const manifest = readBuildManifest(directory);
211
+ const serverFiles = collectServerGraph(directory, manifest);
212
+ const publicFiles = new Set(publicDirectory && existsSync(publicDirectory) ? filesIn(publicDirectory).map((path) => relative(publicDirectory, path).replace(/\\/g, "/")) : []);
213
+ const clientEntries = new Set(Object.values(manifest).filter((value) => typeof value === "string" && value.startsWith("/") && !withinDirectory(directory, value)).map((value) => value.slice(1)));
214
+ const available = filesIn(directory);
215
+ const allowed = new Set(available.filter((path) => path !== resolve(directory, serverBundle) && !serverFiles.has(path) && isClientGraphAsset(relative(directory, path).replace(/\\/g, "/"))));
216
+ const files = available.filter((path) => {
217
+ const name = relative(directory, path).replace(/\\/g, "/");
218
+ return name !== serverBundle && !serverFiles.has(path) && isClientGraphAsset(name) && (publicFiles.has(name) || clientEntries.has(name) || /^(?:chunk-[^/]+|(?:vue|react|svelte|angular|ember|islands|workers|assets|vendor)\/)/.test(name));
219
+ }).sort();
220
+ includeUrlDependencies(files, directory, allowed).sort();
221
+ const hash = createHash("sha256");
222
+ for (const file of files)
223
+ hash.update(relative(directory, file)).update("\x00").update(readFileSync(file)).update("\x00");
224
+ const id = hash.digest("hex");
225
+ const prefix = `${CLIENT_GRAPH_PREFIX}${id}`;
226
+ const urls = Object.create(null);
227
+ for (const file of files) {
228
+ const url = `/${relative(directory, file).replace(/\\/g, "/")}`;
229
+ urls[url] = `${prefix}${url}`;
230
+ }
231
+ const rewriter = compileSpecifierRewriter(urls);
232
+ for (const file of files) {
233
+ const destination = join(directory, prefix.slice(1), relative(directory, file));
234
+ mkdirSync(dirname(destination), { recursive: true });
235
+ const bytes = rewriteGraphAsset(file, rewriter, urls);
236
+ writeFileSync(destination, bytes);
237
+ writeFileSync(file, bytes);
238
+ }
239
+ rewriteManifest(directory, urls);
240
+ return id;
241
+ };
242
+
64
243
  // src/build/externalAssetPlugin.ts
65
- import { copyFileSync, existsSync, mkdirSync, statSync } from "fs";
66
- import { basename, dirname, join, resolve } from "path";
244
+ import { copyFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, statSync } from "fs";
245
+ import { basename, dirname as dirname2, join as join2, resolve as resolve2 } from "path";
67
246
  var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
68
247
  name: "absolute-external-asset",
69
248
  setup(bld) {
70
249
  const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
71
- const skipRoots = userSourceRoots.map((root) => resolve(root));
250
+ const skipRoots = userSourceRoots.map((root) => resolve2(root));
72
251
  const isUserSource = (path) => skipRoots.some((root) => path.startsWith(`${root}/`));
73
252
  bld.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async (args) => {
74
253
  if (isUserSource(args.path))
@@ -78,20 +257,20 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
78
257
  return;
79
258
  urlPattern.lastIndex = 0;
80
259
  let match;
81
- const sourceDir = dirname(args.path);
260
+ const sourceDir = dirname2(args.path);
82
261
  while ((match = urlPattern.exec(source)) !== null) {
83
262
  const relPath = match[1];
84
263
  if (!relPath)
85
264
  continue;
86
- const assetPath = resolve(sourceDir, relPath);
87
- if (!existsSync(assetPath))
265
+ const assetPath = resolve2(sourceDir, relPath);
266
+ if (!existsSync2(assetPath))
88
267
  continue;
89
268
  if (!statSync(assetPath).isFile())
90
269
  continue;
91
- const targetPath = join(outDir, basename(assetPath));
92
- if (existsSync(targetPath))
270
+ const targetPath = join2(outDir, basename(assetPath));
271
+ if (existsSync2(targetPath))
93
272
  continue;
94
- mkdirSync(dirname(targetPath), { recursive: true });
273
+ mkdirSync2(dirname2(targetPath), { recursive: true });
95
274
  copyFileSync(assetPath, targetPath);
96
275
  }
97
276
  return;
@@ -102,23 +281,23 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
102
281
  // src/cli/scripts/compile.ts
103
282
  import {
104
283
  cpSync,
105
- existsSync as existsSync2,
106
- mkdirSync as mkdirSync2,
107
- readdirSync,
108
- readFileSync,
284
+ existsSync as existsSync3,
285
+ mkdirSync as mkdirSync3,
286
+ readdirSync as readdirSync2,
287
+ readFileSync as readFileSync2,
109
288
  rmSync,
110
289
  statSync as statSync2,
111
290
  unlinkSync,
112
- writeFileSync
291
+ writeFileSync as writeFileSync2
113
292
  } from "fs";
114
293
  import { createRequire } from "module";
115
294
  import {
116
295
  basename as basename2,
117
- dirname as dirname2,
118
- isAbsolute,
119
- join as join2,
120
- relative,
121
- resolve as resolve2
296
+ dirname as dirname3,
297
+ isAbsolute as isAbsolute2,
298
+ join as join3,
299
+ relative as relative2,
300
+ resolve as resolve3
122
301
  } from "path";
123
302
  var cliTag = (color, message) => `\x1B[2m${formatTimestamp2()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
124
303
  var compileBanner = (version) => {
@@ -129,14 +308,14 @@ var compileBanner = (version) => {
129
308
  };
130
309
  var collectFiles = (dir) => {
131
310
  const result = [];
132
- let pending = readdirSync(dir, { withFileTypes: true });
311
+ let pending = readdirSync2(dir, { withFileTypes: true });
133
312
  while (pending.length > 0) {
134
313
  const entry = pending.pop();
135
314
  if (!entry)
136
315
  continue;
137
- const fullPath = join2(entry.parentPath, entry.name);
316
+ const fullPath = join3(entry.parentPath, entry.name);
138
317
  if (entry.isDirectory())
139
- pending = pending.concat(readdirSync(fullPath, { withFileTypes: true }));
318
+ pending = pending.concat(readdirSync2(fullPath, { withFileTypes: true }));
140
319
  else
141
320
  result.push(fullPath);
142
321
  }
@@ -144,7 +323,7 @@ var collectFiles = (dir) => {
144
323
  };
145
324
  var INLINE_SOURCE_MAP_RE = /sourceMappingURL=data:application\/json(?:;[^,]+)?;base64,([A-Za-z0-9+/=]+)\s*$/;
146
325
  var rebaseInlineSourceMap = (filePath) => {
147
- const source = readFileSync(filePath, "utf-8");
326
+ const source = readFileSync2(filePath, "utf-8");
148
327
  const match = source.match(INLINE_SOURCE_MAP_RE);
149
328
  const encoded = match?.[1];
150
329
  if (!encoded)
@@ -155,20 +334,20 @@ var rebaseInlineSourceMap = (filePath) => {
155
334
  if (!Array.isArray(map.sources))
156
335
  return;
157
336
  const sourceRoot = typeof map.sourceRoot === "string" ? map.sourceRoot : "";
158
- const bundleDirectory = dirname2(filePath);
337
+ const bundleDirectory = dirname3(filePath);
159
338
  map.sources = map.sources.map((entry) => {
160
339
  if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(entry))
161
340
  return entry;
162
- if (isAbsolute(entry))
341
+ if (isAbsolute2(entry))
163
342
  return entry;
164
343
  if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(sourceRoot)) {
165
344
  return new URL(entry, sourceRoot).href;
166
345
  }
167
- return resolve2(bundleDirectory, sourceRoot, entry);
346
+ return resolve3(bundleDirectory, sourceRoot, entry);
168
347
  });
169
348
  delete map.sourceRoot;
170
349
  const rebased = Buffer.from(JSON.stringify(map)).toString("base64");
171
- writeFileSync(filePath, source.replace(encoded, rebased));
350
+ writeFileSync2(filePath, source.replace(encoded, rebased));
172
351
  };
173
352
  var SERVER_RUNTIME_ASSET_RE = /new\s+URL\(\s*["'](\.\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
174
353
  var SERVER_RUNTIME_IMPORT_META_DIR_JOIN_RE = /(?:join|resolve)\(\s*import\.meta\.dir\s*,\s*((?:(?:"[^"]+"|'[^']+')\s*,?\s*)+)\)/g;
@@ -198,16 +377,16 @@ var normalizeServerRuntimeAssetPath = (parts) => {
198
377
  };
199
378
  var collectProjectSourceFiles = (dir) => {
200
379
  const result = [];
201
- let pending = readdirSync(dir, { withFileTypes: true });
380
+ let pending = readdirSync2(dir, { withFileTypes: true });
202
381
  while (pending.length > 0) {
203
382
  const entry = pending.pop();
204
383
  if (!entry)
205
384
  continue;
206
- const fullPath = join2(entry.parentPath, entry.name);
385
+ const fullPath = join3(entry.parentPath, entry.name);
207
386
  if (entry.isDirectory()) {
208
387
  if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
209
388
  continue;
210
- pending = pending.concat(readdirSync(fullPath, { withFileTypes: true }));
389
+ pending = pending.concat(readdirSync2(fullPath, { withFileTypes: true }));
211
390
  } else if (hasSourceExtension(fullPath)) {
212
391
  result.push(fullPath);
213
392
  }
@@ -216,22 +395,22 @@ var collectProjectSourceFiles = (dir) => {
216
395
  };
217
396
  var copyServerRuntimeAssetReferences = (outdir) => {
218
397
  const copied = new Set;
219
- const normalizedOutdir = resolve2(outdir);
398
+ const normalizedOutdir = resolve3(outdir);
220
399
  const copyReference = (filePath, relPath) => {
221
- const assetSource = resolve2(dirname2(filePath), relPath);
222
- if (!existsSync2(assetSource) || !statSync2(assetSource).isFile())
400
+ const assetSource = resolve3(dirname3(filePath), relPath);
401
+ if (!existsSync3(assetSource) || !statSync2(assetSource).isFile())
223
402
  return;
224
- const assetTarget = resolve2(normalizedOutdir, relPath.replace(/^\.\//, ""));
403
+ const assetTarget = resolve3(normalizedOutdir, relPath.replace(/^\.\//, ""));
225
404
  if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
226
405
  return;
227
406
  if (copied.has(assetTarget))
228
407
  return;
229
408
  copied.add(assetTarget);
230
- mkdirSync2(dirname2(assetTarget), { recursive: true });
409
+ mkdirSync3(dirname3(assetTarget), { recursive: true });
231
410
  cpSync(assetSource, assetTarget, { force: true });
232
411
  };
233
412
  for (const filePath of collectProjectSourceFiles(process.cwd())) {
234
- const source = readFileSync(filePath, "utf-8");
413
+ const source = readFileSync2(filePath, "utf-8");
235
414
  SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
236
415
  let match;
237
416
  while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
@@ -261,7 +440,7 @@ var copyServerRuntimeAssetReferences = (outdir) => {
261
440
  };
262
441
  var readPackageVersion = (candidate) => {
263
442
  try {
264
- const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
443
+ const pkg = JSON.parse(readFileSync2(candidate, "utf-8"));
265
444
  if (pkg.name !== "@absolutejs/absolute")
266
445
  return null;
267
446
  const ver = pkg.version;
@@ -300,18 +479,18 @@ var resolveBuildModule = async (candidates) => {
300
479
  };
301
480
  var resolveJsxDevRuntimeCompatPath = () => {
302
481
  const candidates = [
303
- resolve2(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
304
- resolve2(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
305
- resolve2(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
306
- resolve2(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
307
- resolve2(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
308
- resolve2(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
482
+ resolve3(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
483
+ resolve3(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
484
+ resolve3(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
485
+ resolve3(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
486
+ resolve3(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
487
+ resolve3(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
309
488
  ];
310
489
  for (const candidate of candidates) {
311
- if (existsSync2(candidate))
490
+ if (existsSync3(candidate))
312
491
  return candidate;
313
492
  }
314
- return resolve2(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
493
+ return resolve3(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
315
494
  };
316
495
  var jsxDevRuntimeCompatPath = resolveJsxDevRuntimeCompatPath();
317
496
  var shouldEmbedCompiledAsset = (relativePath, skip = new Set) => {
@@ -342,7 +521,7 @@ var resolveCompileNativeAssets = (buildConfig) => (buildConfig.compile?.nativeAs
342
521
  var requireForCompile = createRequire(import.meta.url);
343
522
  var resolveNativeAssetForRuntime = (specifier) => {
344
523
  if (specifier.startsWith("."))
345
- return resolve2(process.cwd(), specifier);
524
+ return resolve3(process.cwd(), specifier);
346
525
  if (specifier.startsWith("/"))
347
526
  return specifier;
348
527
  return requireForCompile.resolve(specifier, { paths: [process.cwd()] });
@@ -356,12 +535,12 @@ var resolveCompileNativeAssetEnv = (buildConfig) => {
356
535
  };
357
536
  var tryReadNodePackageJson = (packageDir) => {
358
537
  try {
359
- return JSON.parse(readFileSync(join2(packageDir, "package.json"), "utf-8"));
538
+ return JSON.parse(readFileSync2(join3(packageDir, "package.json"), "utf-8"));
360
539
  } catch {
361
540
  return null;
362
541
  }
363
542
  };
364
- var resolveProjectPackageDir = (specifier) => resolve2(process.cwd(), "node_modules", ...specifier.split("/"));
543
+ var resolveProjectPackageDir = (specifier) => resolve3(process.cwd(), "node_modules", ...specifier.split("/"));
365
544
  var copyPackageToBuild = (specifier, outdir, seen) => {
366
545
  if (seen.has(specifier))
367
546
  return;
@@ -370,13 +549,13 @@ var copyPackageToBuild = (specifier, outdir, seen) => {
370
549
  if (!pkg)
371
550
  return;
372
551
  seen.add(specifier);
373
- const destDir = join2(outdir, "node_modules", ...specifier.split("/"));
552
+ const destDir = join3(outdir, "node_modules", ...specifier.split("/"));
374
553
  rmSync(destDir, { force: true, recursive: true });
375
554
  cpSync(srcDir, destDir, {
376
555
  force: true,
377
556
  recursive: true,
378
557
  filter(source) {
379
- const rel = relative(srcDir, source);
558
+ const rel = relative2(srcDir, source);
380
559
  const [firstSegment] = rel.split(/[\\/]/);
381
560
  return firstSegment !== "node_modules" && firstSegment !== ".git";
382
561
  }
@@ -393,8 +572,8 @@ var copyPackageToBuild = (specifier, outdir, seen) => {
393
572
  var copyAngularRuntimePackages = (buildConfig, outdir) => {
394
573
  if (!buildConfig.angularDirectory)
395
574
  return;
396
- const angularScopeDir = resolve2(process.cwd(), "node_modules", "@angular");
397
- const angularPackages = existsSync2(angularScopeDir) ? readdirSync(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
575
+ const angularScopeDir = resolve3(process.cwd(), "node_modules", "@angular");
576
+ const angularPackages = existsSync3(angularScopeDir) ? readdirSync2(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
398
577
  const roots = new Set([...angularPackages, "rxjs", "tslib", "typescript"]);
399
578
  const seen = new Set;
400
579
  for (const specifier of roots) {
@@ -414,16 +593,16 @@ var copyFrameworkRuntimePackages = (buildConfig, outdir) => {
414
593
  copyChunkReferencedPackages(outdir, seen);
415
594
  };
416
595
  var collectRuntimePackageSpecifiers = (distDir) => {
417
- const nodeModulesDir = join2(distDir, "node_modules");
418
- if (!existsSync2(nodeModulesDir))
596
+ const nodeModulesDir = join3(distDir, "node_modules");
597
+ if (!existsSync3(nodeModulesDir))
419
598
  return [];
420
599
  const specifiers = [];
421
- for (const entry of readdirSync(nodeModulesDir, { withFileTypes: true })) {
600
+ for (const entry of readdirSync2(nodeModulesDir, { withFileTypes: true })) {
422
601
  if (!entry.isDirectory())
423
602
  continue;
424
603
  if (entry.name.startsWith("@")) {
425
- const scopeDir = join2(nodeModulesDir, entry.name);
426
- for (const scopedEntry of readdirSync(scopeDir, {
604
+ const scopeDir = join3(nodeModulesDir, entry.name);
605
+ for (const scopedEntry of readdirSync2(scopeDir, {
427
606
  withFileTypes: true
428
607
  })) {
429
608
  if (scopedEntry.isDirectory()) {
@@ -437,7 +616,7 @@ var collectRuntimePackageSpecifiers = (distDir) => {
437
616
  return specifiers.sort((firstSpecifier, secondSpecifier) => secondSpecifier.length - firstSpecifier.length);
438
617
  };
439
618
  var ensureRelativeModuleSpecifier = (fromFile, toFile) => {
440
- const rel = relative(dirname2(fromFile), toFile).replace(/\\/g, "/");
619
+ const rel = relative2(dirname3(fromFile), toFile).replace(/\\/g, "/");
441
620
  return rel.startsWith(".") ? rel : `./${rel}`;
442
621
  };
443
622
  var pickExportEntry = (value) => {
@@ -456,18 +635,18 @@ var resolvePackageEntryFile = (distDir, packageSpecifiers, specifier) => {
456
635
  const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
457
636
  if (!packageSpecifier)
458
637
  return null;
459
- const packageDir = join2(distDir, "node_modules", ...packageSpecifier.split("/"));
638
+ const packageDir = join3(distDir, "node_modules", ...packageSpecifier.split("/"));
460
639
  const subpath = specifier.slice(packageSpecifier.length);
461
- const subPackageDir = subpath ? join2(packageDir, ...subpath.slice(1).split("/")) : null;
462
- const resolvedPackageDir = subPackageDir && existsSync2(join2(subPackageDir, "package.json")) ? subPackageDir : packageDir;
463
- const packageJsonPath = join2(resolvedPackageDir, "package.json");
464
- if (!existsSync2(packageJsonPath))
640
+ const subPackageDir = subpath ? join3(packageDir, ...subpath.slice(1).split("/")) : null;
641
+ const resolvedPackageDir = subPackageDir && existsSync3(join3(subPackageDir, "package.json")) ? subPackageDir : packageDir;
642
+ const packageJsonPath = join3(resolvedPackageDir, "package.json");
643
+ if (!existsSync3(packageJsonPath))
465
644
  return null;
466
- const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
645
+ const pkg = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
467
646
  const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
468
647
  const rootExport = pkg.exports?.[exportKey];
469
648
  const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
470
- return join2(resolvedPackageDir, entry);
649
+ return join3(resolvedPackageDir, entry);
471
650
  };
472
651
  var RUNTIME_JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
473
652
  var MODULE_SPECIFIER_RE = /(from\s*|import\s*|import\(\s*|require\(\s*)(["'])([^"']+)\2/g;
@@ -486,17 +665,17 @@ var resolveRuntimeJsFile = (candidate) => {
486
665
  const candidates = [
487
666
  candidate,
488
667
  ...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
489
- ...RUNTIME_JS_EXTENSIONS.map((extension) => join2(candidate, `index${extension}`))
668
+ ...RUNTIME_JS_EXTENSIONS.map((extension) => join3(candidate, `index${extension}`))
490
669
  ];
491
670
  return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
492
671
  };
493
672
  var findContainingRuntimePackageDir = (filePath) => {
494
- let dir = dirname2(filePath);
495
- while (dir !== dirname2(dir)) {
496
- if (isNodeModulesPath(dir) && existsSync2(join2(dir, "package.json"))) {
673
+ let dir = dirname3(filePath);
674
+ while (dir !== dirname3(dir)) {
675
+ if (isNodeModulesPath(dir) && existsSync3(join3(dir, "package.json"))) {
497
676
  return dir;
498
677
  }
499
- dir = dirname2(dir);
678
+ dir = dirname3(dir);
500
679
  }
501
680
  return null;
502
681
  };
@@ -510,17 +689,17 @@ var resolvePackageImportEntryFile = (fromFile, specifier) => {
510
689
  const entry = pickExportEntry(pkg?.imports?.[specifier]);
511
690
  if (!entry)
512
691
  return null;
513
- return join2(packageDir, entry);
692
+ return join3(packageDir, entry);
514
693
  };
515
694
  var collectRuntimeRewriteRoots = (distDir) => collectFiles(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath));
516
695
  var toTopLevelPackage = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
517
696
  var FRAMEWORK_PACKAGE_NAME = "@absolutejs/absolute";
518
697
  var copyChunkReferencedPackages = (distDir, seen) => {
519
- const distRoot = resolve2(distDir);
698
+ const distRoot = resolve3(distDir);
520
699
  for (const filePath of collectRuntimeRewriteRoots(distDir)) {
521
- if (resolve2(dirname2(filePath)) === distRoot)
700
+ if (resolve3(dirname3(filePath)) === distRoot)
522
701
  continue;
523
- const source = readFileSync(filePath, "utf-8");
702
+ const source = readFileSync2(filePath, "utf-8");
524
703
  for (const match of source.matchAll(MODULE_SPECIFIER_RE)) {
525
704
  const [, , , specifier] = match;
526
705
  if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("bun:")) {
@@ -551,11 +730,11 @@ var rewriteRuntimeModuleSpecifiers = (distDir) => {
551
730
  if (!filePath || seen.has(filePath))
552
731
  continue;
553
732
  seen.add(filePath);
554
- const source = readFileSync(filePath, "utf-8");
733
+ const source = readFileSync2(filePath, "utf-8");
555
734
  const { masked, restore } = maskLiterals(source);
556
735
  const rewrittenMasked = masked.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
557
736
  if (typeof specifier === "string" && specifier.startsWith(".")) {
558
- enqueue(resolveRuntimeJsFile(resolve2(dirname2(filePath), specifier)));
737
+ enqueue(resolveRuntimeJsFile(resolve3(dirname3(filePath), specifier)));
559
738
  return match;
560
739
  }
561
740
  const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
@@ -571,7 +750,7 @@ var rewriteRuntimeModuleSpecifiers = (distDir) => {
571
750
  });
572
751
  const rewritten = restore(rewrittenMasked);
573
752
  if (rewritten !== source) {
574
- writeFileSync(filePath, rewritten);
753
+ writeFileSync2(filePath, rewritten);
575
754
  }
576
755
  }
577
756
  };
@@ -585,12 +764,12 @@ var generateEntrypoint = (distDir, serverEntry, prerenderMap, version, buildConf
585
764
  "_compile_entrypoint.ts"
586
765
  ]);
587
766
  const embeddedFiles = allFiles.filter((file) => {
588
- const rel = relative(distDir, file);
767
+ const rel = relative2(distDir, file);
589
768
  if (embeddedSkip.has(rel))
590
769
  return false;
591
770
  return true;
592
771
  });
593
- const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(relative(distDir, file), assetSkip));
772
+ const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(relative2(distDir, file), assetSkip));
594
773
  const imports = [];
595
774
  const nativeImports = [];
596
775
  const nativeMappings = [];
@@ -600,19 +779,19 @@ var generateEntrypoint = (distDir, serverEntry, prerenderMap, version, buildConf
600
779
  const nativeAssets = resolveCompileNativeAssets(buildConfig);
601
780
  nativeAssets.forEach((asset, idx) => {
602
781
  const varName = `__native${idx}`;
603
- const importSpecifier = asset.import.startsWith(".") ? resolve2(process.cwd(), asset.import) : asset.import;
782
+ const importSpecifier = asset.import.startsWith(".") ? resolve3(process.cwd(), asset.import) : asset.import;
604
783
  nativeImports.push(`import ${varName} from ${JSON.stringify(importSpecifier)} with { type: "file" };`);
605
784
  nativeMappings.push(` [${JSON.stringify(asset.env)}, resolveNativeAssetPath(${varName})],`);
606
785
  });
607
786
  embeddedFiles.forEach((filePath, idx) => {
608
- const rel = relative(distDir, filePath).replace(/\\/g, "/");
787
+ const rel = relative2(distDir, filePath).replace(/\\/g, "/");
609
788
  const varName = `__a${idx}`;
610
789
  embeddedVarMap.set(rel, varName);
611
790
  imports.push(`import ${varName} from "./${rel}" with { type: "file" };`);
612
791
  embeddedMappings.push(` ["${rel}", ${varName}],`);
613
792
  });
614
793
  clientFiles.forEach((filePath) => {
615
- const rel = relative(distDir, filePath).replace(/\\/g, "/");
794
+ const rel = relative2(distDir, filePath).replace(/\\/g, "/");
616
795
  const varName = embeddedVarMap.get(rel);
617
796
  if (!varName)
618
797
  return;
@@ -626,7 +805,7 @@ var generateEntrypoint = (distDir, serverEntry, prerenderMap, version, buildConf
626
805
  const pageVarMap = new Map;
627
806
  const prerenderEntries = Array.from(prerenderMap.entries());
628
807
  prerenderEntries.forEach(([route, filePath]) => {
629
- const rel = relative(distDir, filePath).replace(/\\/g, "/");
808
+ const rel = relative2(distDir, filePath).replace(/\\/g, "/");
630
809
  const varName = embeddedVarMap.get(rel);
631
810
  if (varName)
632
811
  pageVarMap.set(route, varName);
@@ -655,11 +834,12 @@ import { fileURLToPath, pathToFileURL } from "node:url";
655
834
  // ws.data.*). Wiring it into Bun.serve below is what lets compiled servers
656
835
  // serve .ws() routes \u2014 without it every upgrade falls through to a 404.
657
836
  import { buildGlobalWSHandler } from "elysia/ws";
837
+ import { createClientAssetArchive } from ${JSON.stringify([resolve3(import.meta.dir, "../../runtime/clientAssetArchive.ts"), resolve3(import.meta.dir, "../runtime/clientAssetArchive.js")].find((path) => existsSync3(path)))};
658
838
 
659
839
  const SERVER_MODULE = (runtimeDir: string) => import(pathToFileURL(join(runtimeDir, ${JSON.stringify(serverBundleName)})).href);
660
840
  const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
661
841
  const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
662
- const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve2(distDir))};
842
+ const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve3(distDir))};
663
843
  const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
664
844
  const EMBEDDED_NATIVE_AUTH_CLIENTS = ${JSON.stringify(process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV2])};
665
845
 
@@ -696,6 +876,8 @@ ${routeEntries}
696
876
  // \u2500\u2500 MIME types \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
697
877
  const MIME: Record<string, string> = {
698
878
  ".js": "application/javascript; charset=utf-8",
879
+ ".mjs": "application/javascript; charset=utf-8",
880
+ ".wasm": "application/wasm",
699
881
  ".css": "text/css; charset=utf-8",
700
882
  ".html": "text/html; charset=utf-8",
701
883
  ".json": "application/json",
@@ -876,6 +1058,13 @@ const getRuntimeFetch = () => {
876
1058
  return runtimeFetchPromise;
877
1059
  };
878
1060
 
1061
+ let archivedAsset: ((path: string) => Promise<Blob | undefined>) | undefined;
1062
+ try {
1063
+ archivedAsset = await createClientAssetArchive(ASSETS);
1064
+ } catch (error) {
1065
+ console.error("[compile] Client asset retention unavailable:", error);
1066
+ }
1067
+
879
1068
  const server = Bun.serve({
880
1069
  port,
881
1070
  idleTimeout,
@@ -904,11 +1093,14 @@ const server = Bun.serve({
904
1093
  if (page) return servePage(page);
905
1094
 
906
1095
  // Check for embedded asset
907
- const embedded = ASSETS[url.pathname];
1096
+ let assetPath: string;
1097
+ try { assetPath = decodeURIComponent(url.pathname); }
1098
+ catch { return new Response("Malformed asset path", { status: 400 }); }
1099
+ const embedded = ASSETS[url.pathname] ?? ASSETS[assetPath];
908
1100
  if (embedded) {
909
1101
  return new Response(Bun.file(embedded), {
910
1102
  headers: {
911
- "cache-control": isFingerprintedAsset(url.pathname)
1103
+ "cache-control": url.pathname.startsWith("/_absolute/assets/") || isFingerprintedAsset(url.pathname)
912
1104
  ? "public, max-age=31536000, immutable"
913
1105
  : "public, max-age=0, must-revalidate",
914
1106
  "content-type": getMime(url.pathname),
@@ -916,6 +1108,15 @@ const server = Bun.serve({
916
1108
  });
917
1109
  }
918
1110
 
1111
+ if (url.pathname.startsWith("/_absolute/assets/")) {
1112
+ const retained = await archivedAsset?.(url.pathname) ?? await archivedAsset?.(assetPath);
1113
+ if (retained) return new Response(retained, { headers: {
1114
+ "content-type": getMime(url.pathname),
1115
+ "cache-control": "public, max-age=31536000, immutable",
1116
+ "x-content-type-options": "nosniff"
1117
+ } });
1118
+ return new Response("Asset release no longer available. Refresh to load the current release.", { status: 404, headers: { "cache-control": "no-store" } });
1119
+ }
919
1120
  const runtimeFetch = await getRuntimeFetch();
920
1121
  if (runtimeFetch) return runtimeFetch(request);
921
1122
 
@@ -1083,11 +1284,11 @@ var createStubPlugin = (options = {}) => ({
1083
1284
  }
1084
1285
  });
1085
1286
  var compile = async (serverEntry, outdir, outfile, configPath) => {
1086
- const resolvedOutdir = resolve2(outdir ?? "dist");
1287
+ const resolvedOutdir = resolve3(outdir ?? "dist");
1087
1288
  await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath));
1088
1289
  };
1089
1290
  var compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath) => {
1090
- rmSync(join2(resolvedOutdir, "node_modules"), {
1291
+ rmSync(join3(resolvedOutdir, "node_modules"), {
1091
1292
  force: true,
1092
1293
  recursive: true
1093
1294
  });
@@ -1095,13 +1296,17 @@ var compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath) =
1095
1296
  const prerenderPort = configuredPrerenderPort > 0 ? configuredPrerenderPort : await findFreePort();
1096
1297
  killStaleProcesses(prerenderPort);
1097
1298
  const entryName = basename2(serverEntry).replace(/\.[^.]+$/, "");
1098
- const resolvedOutfile = resolve2(outfile ?? "compiled-server");
1299
+ const resolvedOutfile = resolve3(outfile ?? "compiled-server");
1099
1300
  const absoluteVersion = resolvePackageVersion([
1100
- resolve2(import.meta.dir, "..", "..", "..", "package.json"),
1101
- resolve2(import.meta.dir, "..", "..", "package.json")
1301
+ resolve3(import.meta.dir, "..", "..", "..", "package.json"),
1302
+ resolve3(import.meta.dir, "..", "..", "package.json")
1102
1303
  ]);
1103
1304
  compileBanner(absoluteVersion);
1104
1305
  const totalStart = performance.now();
1306
+ rmSync(join3(resolvedOutdir, "_absolute", "assets"), {
1307
+ force: true,
1308
+ recursive: true
1309
+ });
1105
1310
  const buildStart = performance.now();
1106
1311
  process.stdout.write(cliTag("\x1B[36m", "Building assets"));
1107
1312
  const buildConfig = await loadConfig(configPath);
@@ -1111,8 +1316,8 @@ var compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath) =
1111
1316
  installAbsoluteMobileAuthEnvironment2(process.cwd(), normalizeAbsoluteMobileConfig2(buildConfig.mobile, process.cwd()));
1112
1317
  try {
1113
1318
  const build = await resolveBuildModule([
1114
- resolve2(import.meta.dir, "..", "..", "core", "build"),
1115
- resolve2(import.meta.dir, "..", "build")
1319
+ resolve3(import.meta.dir, "..", "..", "core", "build"),
1320
+ resolve3(import.meta.dir, "..", "build")
1116
1321
  ]);
1117
1322
  if (!build)
1118
1323
  throw new Error("Could not locate build module");
@@ -1123,6 +1328,7 @@ var compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath) =
1123
1328
  process.exit(1);
1124
1329
  }
1125
1330
  console.log(` \x1B[2m(${getDurationString(performance.now() - buildStart)})\x1B[0m`);
1331
+ prepareCompiledClientGraph(resolvedOutdir, `${entryName}.js`, buildConfig.publicDirectory);
1126
1332
  const bundleStart = performance.now();
1127
1333
  process.stdout.write(cliTag("\x1B[36m", "Bundling production server"));
1128
1334
  const userSourceRoots = [
@@ -1134,12 +1340,12 @@ var compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath) =
1134
1340
  buildConfig.htmxDirectory
1135
1341
  ].filter((dir) => Boolean(dir));
1136
1342
  const islandRegistrySpec = buildConfig.islands?.registry;
1137
- const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve2(islandRegistrySpec))) : undefined;
1138
- const serverBundleEntryDirectory = join2(resolvedOutdir, ".absolutejs-server-entry");
1139
- mkdirSync2(serverBundleEntryDirectory, { recursive: true });
1140
- const typeboxSetupEntry = join2(serverBundleEntryDirectory, "_typebox_setup.ts");
1141
- const serverBundleEntry = join2(serverBundleEntryDirectory, basename2(serverEntry));
1142
- writeFileSync(typeboxSetupEntry, `import { setupTypebox } from 'elysia';
1343
+ const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve3(islandRegistrySpec))) : undefined;
1344
+ const serverBundleEntryDirectory = join3(resolvedOutdir, ".absolutejs-server-entry");
1345
+ mkdirSync3(serverBundleEntryDirectory, { recursive: true });
1346
+ const typeboxSetupEntry = join3(serverBundleEntryDirectory, "_typebox_setup.ts");
1347
+ const serverBundleEntry = join3(serverBundleEntryDirectory, basename2(serverEntry));
1348
+ writeFileSync2(typeboxSetupEntry, `import { setupTypebox } from 'elysia';
1143
1349
  import * as compile from 'typebox/compile';
1144
1350
  import * as schema from 'typebox/schema';
1145
1351
  import * as system from 'typebox/system';
@@ -1148,8 +1354,8 @@ import * as value from 'typebox/value';
1148
1354
 
1149
1355
  setupTypebox({ typebox: { compile, schema, system, type, value } });
1150
1356
  `);
1151
- writeFileSync(serverBundleEntry, `import './_typebox_setup';
1152
- import * as serverModule from ${JSON.stringify(resolve2(serverEntry))};
1357
+ writeFileSync2(serverBundleEntry, `import './_typebox_setup';
1358
+ import * as serverModule from ${JSON.stringify(resolve3(serverEntry))};
1153
1359
 
1154
1360
  export const server = serverModule.server ?? serverModule.app ?? serverModule.default;
1155
1361
  export default server;
@@ -1164,7 +1370,7 @@ export default server;
1164
1370
  ...islandRegistryPlugin ? [islandRegistryPlugin] : [],
1165
1371
  ...buildConfig.mobile ? [
1166
1372
  createAbsoluteMobileRouteMetadataPlugin({
1167
- entry: resolve2(serverEntry)
1373
+ entry: resolve3(serverEntry)
1168
1374
  })
1169
1375
  ] : [],
1170
1376
  createElysiaOpenApiTypeboxPlugin(),
@@ -1188,14 +1394,14 @@ export default server;
1188
1394
  console.error(cliTag("\x1B[31m", "Server bundle failed."));
1189
1395
  process.exit(1);
1190
1396
  }
1191
- const outputPath = resolve2(resolvedOutdir, `${entryName}.js`);
1192
- if (!existsSync2(outputPath)) {
1397
+ const outputPath = resolve3(resolvedOutdir, `${entryName}.js`);
1398
+ if (!existsSync3(outputPath)) {
1193
1399
  console.error(cliTag("\x1B[31m", `Expected output not found: ${outputPath}`));
1194
1400
  process.exit(1);
1195
1401
  }
1196
- if (existsSync2(resolve2(resolvedOutdir, "angular", "vendor", "server"))) {
1197
- const vendorDir = resolve2(resolvedOutdir, "angular", "vendor", "server");
1198
- const vendorEntries = readdirSync(vendorDir).filter((fileName) => fileName.endsWith(".js"));
1402
+ if (existsSync3(resolve3(resolvedOutdir, "angular", "vendor", "server"))) {
1403
+ const vendorDir = resolve3(resolvedOutdir, "angular", "vendor", "server");
1404
+ const vendorEntries = readdirSync2(vendorDir).filter((fileName) => fileName.endsWith(".js"));
1199
1405
  const angularServerVendorPaths = {};
1200
1406
  for (const file of vendorEntries) {
1201
1407
  const stem = file.replace(/\.js$/, "");
@@ -1203,11 +1409,11 @@ export default server;
1203
1409
  if (scope !== "angular" || rest.length === 0)
1204
1410
  continue;
1205
1411
  const specifier = `@angular/${rest.join("/")}`;
1206
- const relPath = relative(dirname2(outputPath), resolve2(vendorDir, file));
1412
+ const relPath = relative2(dirname3(outputPath), resolve3(vendorDir, file));
1207
1413
  angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
1208
1414
  }
1209
1415
  if (Object.keys(angularServerVendorPaths).length > 0) {
1210
- const { rewriteImports } = await import("./rewriteImports-k6rjjmg1.js");
1416
+ const { rewriteImports } = await import("./rewriteImports-z6629aww.js");
1211
1417
  await rewriteImports([outputPath], angularServerVendorPaths);
1212
1418
  }
1213
1419
  }
@@ -1215,7 +1421,7 @@ export default server;
1215
1421
  copyServerRuntimeAssetReferences(resolvedOutdir);
1216
1422
  const prerenderStart = performance.now();
1217
1423
  process.stdout.write(cliTag("\x1B[36m", "Pre-rendering pages"));
1218
- rmSync(join2(resolvedOutdir, "_prerendered"), {
1424
+ rmSync(join3(resolvedOutdir, "_prerendered"), {
1219
1425
  force: true,
1220
1426
  recursive: true
1221
1427
  });
@@ -1245,9 +1451,9 @@ export default server;
1245
1451
  const compileStart = performance.now();
1246
1452
  process.stdout.write(cliTag("\x1B[36m", "Compiling standalone executable"));
1247
1453
  const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
1248
- const entrypointPath = join2(resolvedOutdir, "_compile_entrypoint.ts");
1454
+ const entrypointPath = join3(resolvedOutdir, "_compile_entrypoint.ts");
1249
1455
  await Bun.write(entrypointPath, entrypointCode);
1250
- mkdirSync2(dirname2(resolvedOutfile), { recursive: true });
1456
+ mkdirSync3(dirname3(resolvedOutfile), { recursive: true });
1251
1457
  const result = await Bun.build({
1252
1458
  compile: { outfile: resolvedOutfile },
1253
1459
  define: { "process.env.NODE_ENV": '"production"' },