@absolutejs/absolute 0.19.0-beta.756 → 0.19.0-beta.758

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.
@@ -2536,7 +2536,10 @@ var getDurationString = (duration) => {
2536
2536
  } else if (duration < MILLISECONDS_IN_A_MINUTE) {
2537
2537
  durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
2538
2538
  } else {
2539
- durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
2539
+ const totalSeconds = Math.round(duration / MILLISECONDS_IN_A_SECOND);
2540
+ const minutes = Math.floor(totalSeconds / 60);
2541
+ const seconds = totalSeconds % 60;
2542
+ durationString = seconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`;
2540
2543
  }
2541
2544
  return durationString;
2542
2545
  };
@@ -3219,6 +3222,7 @@ var init_lowerDeferSyntax = __esm(() => {
3219
3222
  // src/build/compileAngular.ts
3220
3223
  var exports_compileAngular = {};
3221
3224
  __export(exports_compileAngular, {
3225
+ compileAngularFiles: () => compileAngularFiles,
3222
3226
  compileAngularFileJIT: () => compileAngularFileJIT,
3223
3227
  compileAngularFile: () => compileAngularFile,
3224
3228
  compileAngular: () => compileAngular
@@ -3226,15 +3230,7 @@ __export(exports_compileAngular, {
3226
3230
  import { existsSync as existsSync5, readFileSync as readFileSync4, promises as fs } from "fs";
3227
3231
  import { join as join5, basename as basename3, sep, dirname as dirname4, resolve as resolve6, relative as relative3 } from "path";
3228
3232
  import ts from "typescript";
3229
- import { createHash } from "crypto";
3230
- var computeConfigHash = () => {
3231
- try {
3232
- const content = readFileSync4("./tsconfig.json", "utf-8");
3233
- return createHash("md5").update(content).digest("hex");
3234
- } catch {
3235
- return "";
3236
- }
3237
- }, readTsconfigPathAliases = () => {
3233
+ var readTsconfigPathAliases = () => {
3238
3234
  try {
3239
3235
  const configPath = resolve6(process.cwd(), "tsconfig.json");
3240
3236
  const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
@@ -3385,6 +3381,21 @@ ${registrations}
3385
3381
  if (fileName.startsWith(outDir))
3386
3382
  return fileName.substring(outDir.length + 1);
3387
3383
  return fileName;
3384
+ }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
3385
+ if (specifier.endsWith(".ts"))
3386
+ return specifier.replace(/\.ts$/, ".js");
3387
+ if (hasJsLikeExtension(specifier))
3388
+ return specifier;
3389
+ const importerDir = dirname4(importerOutputPath);
3390
+ const fileCandidate = resolve6(importerDir, `${specifier}.js`);
3391
+ if (outputFiles?.has(fileCandidate) || existsSync5(fileCandidate)) {
3392
+ return `${specifier}.js`;
3393
+ }
3394
+ const indexCandidate = resolve6(importerDir, specifier, "index.js");
3395
+ if (outputFiles?.has(indexCandidate) || existsSync5(indexCandidate)) {
3396
+ return `${specifier}/index.js`;
3397
+ }
3398
+ return `${specifier}.js`;
3388
3399
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
3389
3400
  const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
3390
3401
  const specifiers = [];
@@ -3425,7 +3436,7 @@ ${registrations}
3425
3436
  if (typeof hostSource === "string")
3426
3437
  return hostSource;
3427
3438
  return fs.readFile(fileName, "utf-8");
3428
- }, precomputeAotResourceTransforms = async (inputPath, readFile2, stylePreprocessors) => {
3439
+ }, precomputeAotResourceTransforms = async (inputPaths, readFile2, stylePreprocessors) => {
3429
3440
  const transformedSources = new Map;
3430
3441
  const visited = new Set;
3431
3442
  const transformFile = async (filePath) => {
@@ -3445,70 +3456,59 @@ ${registrations}
3445
3456
  await transformFile(resolvedImport);
3446
3457
  }));
3447
3458
  };
3448
- await transformFile(inputPath);
3459
+ await Promise.all(inputPaths.map((inputPath) => transformFile(inputPath)));
3449
3460
  return transformedSources;
3450
- }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
3451
- const islandMetadataExports = buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"));
3461
+ }, compileAngularFiles = async (inputPaths, outDir, stylePreprocessors) => {
3462
+ const islandMetadataByOutputPath = new Map(inputPaths.map((inputPath) => {
3463
+ const outputPath = resolve6(join5(outDir, relative3(process.cwd(), resolve6(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
3464
+ return [
3465
+ outputPath,
3466
+ buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"))
3467
+ ];
3468
+ }));
3452
3469
  const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
3453
- const configHash = computeConfigHash();
3454
- const cached = globalThis.__angularCompilerCache;
3455
- let host;
3456
- let options;
3457
- let tsLibDir;
3458
- if (cached && cached.configHash === configHash) {
3459
- ({ host } = cached);
3460
- options = { ...cached.options, outDir, rootDir: process.cwd() };
3461
- ({ tsLibDir } = cached);
3462
- cached.lastUsed = Date.now();
3463
- } else {
3464
- const tsPath = __require.resolve("typescript");
3465
- const tsRootDir = dirname4(tsPath);
3466
- tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve6(tsRootDir, "lib");
3467
- const config = readConfiguration("./tsconfig.json");
3468
- options = {
3469
- emitDecoratorMetadata: true,
3470
- esModuleInterop: true,
3471
- experimentalDecorators: true,
3472
- module: ts.ModuleKind.ESNext,
3473
- moduleResolution: ts.ModuleResolutionKind.Bundler,
3474
- newLine: ts.NewLineKind.LineFeed,
3475
- noLib: false,
3476
- outDir,
3477
- skipLibCheck: true,
3478
- target: ts.ScriptTarget.ES2022,
3479
- ...config.options
3480
- };
3481
- options.target = ts.ScriptTarget.ES2022;
3482
- options.experimentalDecorators = true;
3483
- options.emitDecoratorMetadata = true;
3484
- options.newLine = ts.NewLineKind.LineFeed;
3485
- options.outDir = outDir;
3486
- options.noEmit = false;
3487
- options.rootDir = process.cwd();
3488
- host = ts.createCompilerHost(options);
3489
- const originalGetDefaultLibLocation = host.getDefaultLibLocation;
3490
- host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
3491
- const originalGetDefaultLibFileName = host.getDefaultLibFileName;
3492
- host.getDefaultLibFileName = (opts) => {
3493
- const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
3494
- return basename3(fileName);
3495
- };
3496
- const originalGetSourceFile = host.getSourceFile;
3497
- host.getSourceFile = (fileName, languageVersion, onError) => {
3498
- if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
3499
- const resolvedPath = join5(tsLibDir, fileName);
3500
- return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
3501
- }
3502
- return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
3503
- };
3504
- globalThis.__angularCompilerCache = {
3505
- configHash,
3506
- host,
3507
- lastUsed: Date.now(),
3508
- options: { ...options },
3509
- tsLibDir
3510
- };
3511
- }
3470
+ const tsPath = __require.resolve("typescript");
3471
+ const tsRootDir = dirname4(tsPath);
3472
+ const tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve6(tsRootDir, "lib");
3473
+ const config = readConfiguration("./tsconfig.json");
3474
+ const options = {
3475
+ emitDecoratorMetadata: true,
3476
+ esModuleInterop: true,
3477
+ experimentalDecorators: true,
3478
+ module: ts.ModuleKind.ESNext,
3479
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
3480
+ newLine: ts.NewLineKind.LineFeed,
3481
+ noLib: false,
3482
+ outDir,
3483
+ skipLibCheck: true,
3484
+ target: ts.ScriptTarget.ES2022,
3485
+ ...config.options
3486
+ };
3487
+ options.target = ts.ScriptTarget.ES2022;
3488
+ options.experimentalDecorators = true;
3489
+ options.emitDecoratorMetadata = true;
3490
+ options.newLine = ts.NewLineKind.LineFeed;
3491
+ options.outDir = outDir;
3492
+ options.noEmit = false;
3493
+ options.incremental = false;
3494
+ options.tsBuildInfoFile = undefined;
3495
+ options.rootDir = process.cwd();
3496
+ const host = ts.createCompilerHost(options);
3497
+ const originalGetDefaultLibLocation = host.getDefaultLibLocation;
3498
+ host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
3499
+ const originalGetDefaultLibFileName = host.getDefaultLibFileName;
3500
+ host.getDefaultLibFileName = (opts) => {
3501
+ const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
3502
+ return basename3(fileName);
3503
+ };
3504
+ const originalGetSourceFile = host.getSourceFile;
3505
+ host.getSourceFile = (fileName, languageVersion, onError) => {
3506
+ if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
3507
+ const resolvedPath = join5(tsLibDir, fileName);
3508
+ return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
3509
+ }
3510
+ return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
3511
+ };
3512
3512
  const emitted = {};
3513
3513
  const resolvedOutDir = resolve6(outDir);
3514
3514
  host.writeFile = (fileName, text) => {
@@ -3516,7 +3516,7 @@ ${registrations}
3516
3516
  emitted[relativePath] = text;
3517
3517
  };
3518
3518
  const originalReadFile = host.readFile;
3519
- const aotTransformedSources = await precomputeAotResourceTransforms(inputPath, originalReadFile?.bind(host), stylePreprocessors);
3519
+ const aotTransformedSources = await precomputeAotResourceTransforms(inputPaths, originalReadFile?.bind(host), stylePreprocessors);
3520
3520
  host.readFile = (fileName) => {
3521
3521
  const source = originalReadFile ? originalReadFile.call(host, fileName) : undefined;
3522
3522
  if (typeof source !== "string")
@@ -3541,18 +3541,23 @@ ${registrations}
3541
3541
  emitFlags: EmitFlags.Default,
3542
3542
  host,
3543
3543
  options,
3544
- rootNames: [inputPath]
3544
+ rootNames: inputPaths
3545
3545
  }));
3546
3546
  } finally {
3547
3547
  host.readFile = originalReadFile;
3548
3548
  host.getSourceFile = originalGetSourceFileForCompile;
3549
3549
  }
3550
3550
  throwOnCompilationErrors(diagnostics);
3551
- const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
3552
- const target = join5(outDir, fileName);
3551
+ const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
3552
+ content,
3553
+ target: join5(outDir, fileName)
3554
+ }));
3555
+ const outputFiles = new Set(rawEntries.map(({ target }) => resolve6(target)));
3556
+ const entries = rawEntries.map(({ content, target }) => {
3553
3557
  let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
3554
- if (!path.match(/\.(js|ts|mjs|cjs)$/)) {
3555
- return `from ${quote}${path}.js${quote}`;
3558
+ const rewritten = rewriteRelativeJsSpecifier(target, path, outputFiles);
3559
+ if (rewritten !== path) {
3560
+ return `from ${quote}${rewritten}${quote}`;
3556
3561
  }
3557
3562
  return match;
3558
3563
  });
@@ -3562,13 +3567,13 @@ ${registrations}
3562
3567
  return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
3563
3568
  });
3564
3569
  processedContent = processedContent.replace(/\b(?<!Internal)InjectFlags\b/g, "InternalInjectFlags");
3565
- processedContent += islandMetadataExports;
3570
+ processedContent += islandMetadataByOutputPath.get(resolve6(target)) ?? "";
3566
3571
  return { content: processedContent, target };
3567
3572
  });
3568
3573
  await Promise.all(entries.map(({ target }) => fs.mkdir(dirname4(target), { recursive: true })));
3569
3574
  await Promise.all(entries.map(({ target, content }) => fs.writeFile(target, content, "utf-8")));
3570
3575
  return entries.map(({ target }) => target);
3571
- }, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), findUncommentedMatch = (source, pattern) => {
3576
+ }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => compileAngularFiles([inputPath], outDir, stylePreprocessors), jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), findUncommentedMatch = (source, pattern) => {
3572
3577
  const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g");
3573
3578
  let match;
3574
3579
  while ((match = re.exec(source)) !== null) {
@@ -3865,6 +3870,7 @@ ${fields}
3865
3870
  };
3866
3871
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
3867
3872
  let processedContent = angularTranspiler.transformSync(sourceCode);
3873
+ const outputPath = toOutputPath(actualPath);
3868
3874
  const rewriteBareImport = (prefix, specifier, suffix) => {
3869
3875
  const rewritten = importRewrites.get(specifier);
3870
3876
  if (rewritten) {
@@ -3879,11 +3885,9 @@ ${fields}
3879
3885
  processedContent = processedContent.replace(/(import\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
3880
3886
  processedContent = processedContent.replace(/(import\(\s*['"])([^'"]+)(['"]\s*\))/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
3881
3887
  processedContent = processedContent.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
3882
- if (!path.match(/\.(js|ts|mjs|cjs)$/)) {
3883
- return `from ${quote}${path}.js${quote}`;
3884
- }
3885
- if (path.endsWith(".ts")) {
3886
- return `from ${quote}${path.replace(/\.ts$/, ".js")}${quote}`;
3888
+ const rewritten = rewriteRelativeJsSpecifier(outputPath, path);
3889
+ if (rewritten !== path) {
3890
+ return `from ${quote}${rewritten}${quote}`;
3887
3891
  }
3888
3892
  return match;
3889
3893
  });
@@ -3977,11 +3981,12 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
3977
3981
  const compiledRoot = compiledParent;
3978
3982
  const indexesDir = join5(compiledParent, "indexes");
3979
3983
  await fs.mkdir(indexesDir, { recursive: true });
3984
+ const aotOutputs = hmr ? [] : await compileAngularFiles(entryPoints.map((entry) => resolve6(entry)), compiledRoot, stylePreprocessors);
3980
3985
  const compileTasks = entryPoints.map(async (entry) => {
3981
3986
  const resolvedEntry = resolve6(entry);
3982
3987
  const relativeEntry = relative3(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
3983
- const compileEntry = () => hmr ? compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors) : compileAngularFile(resolvedEntry, compiledRoot, stylePreprocessors);
3984
- let outputs = await compileEntry();
3988
+ const compileEntry = () => compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors);
3989
+ let outputs = hmr ? await compileEntry() : aotOutputs;
3985
3990
  const fileBase = basename3(resolvedEntry).replace(/\.[tj]s$/, "");
3986
3991
  const jsName = `${fileBase}.js`;
3987
3992
  const compiledFallbackPaths = [
@@ -4008,7 +4013,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
4008
4013
  rawServerFile = resolveRawServerFile([]);
4009
4014
  }
4010
4015
  if (rawServerFile && !existsSync5(rawServerFile)) {
4011
- outputs = await compileEntry();
4016
+ outputs = hmr ? await compileEntry() : aotOutputs;
4012
4017
  rawServerFile = resolveRawServerFile(outputs);
4013
4018
  }
4014
4019
  if (!rawServerFile || !existsSync5(rawServerFile)) {
@@ -5449,5 +5454,5 @@ export {
5449
5454
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
5450
5455
  };
5451
5456
 
5452
- //# debugId=76CAE04381DA5DEA64756E2164756E21
5457
+ //# debugId=E05F6DFD53809BC964756E2164756E21
5453
5458
  //# sourceMappingURL=server.js.map