@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.
package/dist/build.js CHANGED
@@ -113,7 +113,10 @@ var getDurationString = (duration) => {
113
113
  } else if (duration < MILLISECONDS_IN_A_MINUTE) {
114
114
  durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
115
115
  } else {
116
- durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
116
+ const totalSeconds = Math.round(duration / MILLISECONDS_IN_A_SECOND);
117
+ const minutes = Math.floor(totalSeconds / 60);
118
+ const seconds = totalSeconds % 60;
119
+ durationString = seconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`;
117
120
  }
118
121
  return durationString;
119
122
  };
@@ -43498,6 +43501,7 @@ var init_lowerDeferSyntax = __esm(() => {
43498
43501
  // src/build/compileAngular.ts
43499
43502
  var exports_compileAngular = {};
43500
43503
  __export(exports_compileAngular, {
43504
+ compileAngularFiles: () => compileAngularFiles,
43501
43505
  compileAngularFileJIT: () => compileAngularFileJIT,
43502
43506
  compileAngularFile: () => compileAngularFile,
43503
43507
  compileAngular: () => compileAngular
@@ -43505,15 +43509,7 @@ __export(exports_compileAngular, {
43505
43509
  import { existsSync as existsSync16, readFileSync as readFileSync9, promises as fs2 } from "fs";
43506
43510
  import { join as join15, basename as basename6, sep as sep3, dirname as dirname10, resolve as resolve16, relative as relative9 } from "path";
43507
43511
  import ts2 from "typescript";
43508
- import { createHash as createHash2 } from "crypto";
43509
- var computeConfigHash = () => {
43510
- try {
43511
- const content = readFileSync9("./tsconfig.json", "utf-8");
43512
- return createHash2("md5").update(content).digest("hex");
43513
- } catch {
43514
- return "";
43515
- }
43516
- }, readTsconfigPathAliases = () => {
43512
+ var readTsconfigPathAliases = () => {
43517
43513
  try {
43518
43514
  const configPath2 = resolve16(process.cwd(), "tsconfig.json");
43519
43515
  const config = ts2.readConfigFile(configPath2, ts2.sys.readFile).config;
@@ -43664,6 +43660,21 @@ ${registrations}
43664
43660
  if (fileName.startsWith(outDir))
43665
43661
  return fileName.substring(outDir.length + 1);
43666
43662
  return fileName;
43663
+ }, hasJsLikeExtension = (path2) => /\.(js|ts|mjs|cjs)$/.test(path2), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
43664
+ if (specifier.endsWith(".ts"))
43665
+ return specifier.replace(/\.ts$/, ".js");
43666
+ if (hasJsLikeExtension(specifier))
43667
+ return specifier;
43668
+ const importerDir = dirname10(importerOutputPath);
43669
+ const fileCandidate = resolve16(importerDir, `${specifier}.js`);
43670
+ if (outputFiles?.has(fileCandidate) || existsSync16(fileCandidate)) {
43671
+ return `${specifier}.js`;
43672
+ }
43673
+ const indexCandidate = resolve16(importerDir, specifier, "index.js");
43674
+ if (outputFiles?.has(indexCandidate) || existsSync16(indexCandidate)) {
43675
+ return `${specifier}/index.js`;
43676
+ }
43677
+ return `${specifier}.js`;
43667
43678
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
43668
43679
  const sourceFile = ts2.createSourceFile(fileName, source, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
43669
43680
  const specifiers = [];
@@ -43704,7 +43715,7 @@ ${registrations}
43704
43715
  if (typeof hostSource === "string")
43705
43716
  return hostSource;
43706
43717
  return fs2.readFile(fileName, "utf-8");
43707
- }, precomputeAotResourceTransforms = async (inputPath, readFile4, stylePreprocessors) => {
43718
+ }, precomputeAotResourceTransforms = async (inputPaths, readFile4, stylePreprocessors) => {
43708
43719
  const transformedSources = new Map;
43709
43720
  const visited = new Set;
43710
43721
  const transformFile = async (filePath) => {
@@ -43724,70 +43735,59 @@ ${registrations}
43724
43735
  await transformFile(resolvedImport);
43725
43736
  }));
43726
43737
  };
43727
- await transformFile(inputPath);
43738
+ await Promise.all(inputPaths.map((inputPath) => transformFile(inputPath)));
43728
43739
  return transformedSources;
43729
- }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
43730
- const islandMetadataExports = buildIslandMetadataExports(readFileSync9(inputPath, "utf-8"));
43740
+ }, compileAngularFiles = async (inputPaths, outDir, stylePreprocessors) => {
43741
+ const islandMetadataByOutputPath = new Map(inputPaths.map((inputPath) => {
43742
+ const outputPath = resolve16(join15(outDir, relative9(process.cwd(), resolve16(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
43743
+ return [
43744
+ outputPath,
43745
+ buildIslandMetadataExports(readFileSync9(inputPath, "utf-8"))
43746
+ ];
43747
+ }));
43731
43748
  const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
43732
- const configHash = computeConfigHash();
43733
- const cached = globalThis.__angularCompilerCache;
43734
- let host;
43735
- let options;
43736
- let tsLibDir;
43737
- if (cached && cached.configHash === configHash) {
43738
- ({ host } = cached);
43739
- options = { ...cached.options, outDir, rootDir: process.cwd() };
43740
- ({ tsLibDir } = cached);
43741
- cached.lastUsed = Date.now();
43742
- } else {
43743
- const tsPath = __require.resolve("typescript");
43744
- const tsRootDir = dirname10(tsPath);
43745
- tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve16(tsRootDir, "lib");
43746
- const config = readConfiguration("./tsconfig.json");
43747
- options = {
43748
- emitDecoratorMetadata: true,
43749
- esModuleInterop: true,
43750
- experimentalDecorators: true,
43751
- module: ts2.ModuleKind.ESNext,
43752
- moduleResolution: ts2.ModuleResolutionKind.Bundler,
43753
- newLine: ts2.NewLineKind.LineFeed,
43754
- noLib: false,
43755
- outDir,
43756
- skipLibCheck: true,
43757
- target: ts2.ScriptTarget.ES2022,
43758
- ...config.options
43759
- };
43760
- options.target = ts2.ScriptTarget.ES2022;
43761
- options.experimentalDecorators = true;
43762
- options.emitDecoratorMetadata = true;
43763
- options.newLine = ts2.NewLineKind.LineFeed;
43764
- options.outDir = outDir;
43765
- options.noEmit = false;
43766
- options.rootDir = process.cwd();
43767
- host = ts2.createCompilerHost(options);
43768
- const originalGetDefaultLibLocation = host.getDefaultLibLocation;
43769
- host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
43770
- const originalGetDefaultLibFileName = host.getDefaultLibFileName;
43771
- host.getDefaultLibFileName = (opts) => {
43772
- const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
43773
- return basename6(fileName);
43774
- };
43775
- const originalGetSourceFile = host.getSourceFile;
43776
- host.getSourceFile = (fileName, languageVersion, onError2) => {
43777
- if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
43778
- const resolvedPath = join15(tsLibDir, fileName);
43779
- return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError2);
43780
- }
43781
- return originalGetSourceFile?.call(host, fileName, languageVersion, onError2);
43782
- };
43783
- globalThis.__angularCompilerCache = {
43784
- configHash,
43785
- host,
43786
- lastUsed: Date.now(),
43787
- options: { ...options },
43788
- tsLibDir
43789
- };
43790
- }
43749
+ const tsPath = __require.resolve("typescript");
43750
+ const tsRootDir = dirname10(tsPath);
43751
+ const tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve16(tsRootDir, "lib");
43752
+ const config = readConfiguration("./tsconfig.json");
43753
+ const options = {
43754
+ emitDecoratorMetadata: true,
43755
+ esModuleInterop: true,
43756
+ experimentalDecorators: true,
43757
+ module: ts2.ModuleKind.ESNext,
43758
+ moduleResolution: ts2.ModuleResolutionKind.Bundler,
43759
+ newLine: ts2.NewLineKind.LineFeed,
43760
+ noLib: false,
43761
+ outDir,
43762
+ skipLibCheck: true,
43763
+ target: ts2.ScriptTarget.ES2022,
43764
+ ...config.options
43765
+ };
43766
+ options.target = ts2.ScriptTarget.ES2022;
43767
+ options.experimentalDecorators = true;
43768
+ options.emitDecoratorMetadata = true;
43769
+ options.newLine = ts2.NewLineKind.LineFeed;
43770
+ options.outDir = outDir;
43771
+ options.noEmit = false;
43772
+ options.incremental = false;
43773
+ options.tsBuildInfoFile = undefined;
43774
+ options.rootDir = process.cwd();
43775
+ const host = ts2.createCompilerHost(options);
43776
+ const originalGetDefaultLibLocation = host.getDefaultLibLocation;
43777
+ host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
43778
+ const originalGetDefaultLibFileName = host.getDefaultLibFileName;
43779
+ host.getDefaultLibFileName = (opts) => {
43780
+ const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
43781
+ return basename6(fileName);
43782
+ };
43783
+ const originalGetSourceFile = host.getSourceFile;
43784
+ host.getSourceFile = (fileName, languageVersion, onError2) => {
43785
+ if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
43786
+ const resolvedPath = join15(tsLibDir, fileName);
43787
+ return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError2);
43788
+ }
43789
+ return originalGetSourceFile?.call(host, fileName, languageVersion, onError2);
43790
+ };
43791
43791
  const emitted = {};
43792
43792
  const resolvedOutDir = resolve16(outDir);
43793
43793
  host.writeFile = (fileName, text) => {
@@ -43795,7 +43795,7 @@ ${registrations}
43795
43795
  emitted[relativePath] = text;
43796
43796
  };
43797
43797
  const originalReadFile = host.readFile;
43798
- const aotTransformedSources = await precomputeAotResourceTransforms(inputPath, originalReadFile?.bind(host), stylePreprocessors);
43798
+ const aotTransformedSources = await precomputeAotResourceTransforms(inputPaths, originalReadFile?.bind(host), stylePreprocessors);
43799
43799
  host.readFile = (fileName) => {
43800
43800
  const source = originalReadFile ? originalReadFile.call(host, fileName) : undefined;
43801
43801
  if (typeof source !== "string")
@@ -43820,18 +43820,23 @@ ${registrations}
43820
43820
  emitFlags: EmitFlags.Default,
43821
43821
  host,
43822
43822
  options,
43823
- rootNames: [inputPath]
43823
+ rootNames: inputPaths
43824
43824
  }));
43825
43825
  } finally {
43826
43826
  host.readFile = originalReadFile;
43827
43827
  host.getSourceFile = originalGetSourceFileForCompile;
43828
43828
  }
43829
43829
  throwOnCompilationErrors(diagnostics);
43830
- const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
43831
- const target = join15(outDir, fileName);
43830
+ const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
43831
+ content,
43832
+ target: join15(outDir, fileName)
43833
+ }));
43834
+ const outputFiles = new Set(rawEntries.map(({ target }) => resolve16(target)));
43835
+ const entries = rawEntries.map(({ content, target }) => {
43832
43836
  let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path2) => {
43833
- if (!path2.match(/\.(js|ts|mjs|cjs)$/)) {
43834
- return `from ${quote}${path2}.js${quote}`;
43837
+ const rewritten = rewriteRelativeJsSpecifier(target, path2, outputFiles);
43838
+ if (rewritten !== path2) {
43839
+ return `from ${quote}${rewritten}${quote}`;
43835
43840
  }
43836
43841
  return match;
43837
43842
  });
@@ -43841,13 +43846,13 @@ ${registrations}
43841
43846
  return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
43842
43847
  });
43843
43848
  processedContent = processedContent.replace(/\b(?<!Internal)InjectFlags\b/g, "InternalInjectFlags");
43844
- processedContent += islandMetadataExports;
43849
+ processedContent += islandMetadataByOutputPath.get(resolve16(target)) ?? "";
43845
43850
  return { content: processedContent, target };
43846
43851
  });
43847
43852
  await Promise.all(entries.map(({ target }) => fs2.mkdir(dirname10(target), { recursive: true })));
43848
43853
  await Promise.all(entries.map(({ target, content }) => fs2.writeFile(target, content, "utf-8")));
43849
43854
  return entries.map(({ target }) => target);
43850
- }, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), findUncommentedMatch = (source, pattern) => {
43855
+ }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => compileAngularFiles([inputPath], outDir, stylePreprocessors), jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), findUncommentedMatch = (source, pattern) => {
43851
43856
  const re2 = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g");
43852
43857
  let match;
43853
43858
  while ((match = re2.exec(source)) !== null) {
@@ -44144,6 +44149,7 @@ ${fields}
44144
44149
  };
44145
44150
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
44146
44151
  let processedContent = angularTranspiler.transformSync(sourceCode);
44152
+ const outputPath = toOutputPath(actualPath);
44147
44153
  const rewriteBareImport = (prefix, specifier, suffix) => {
44148
44154
  const rewritten = importRewrites.get(specifier);
44149
44155
  if (rewritten) {
@@ -44158,11 +44164,9 @@ ${fields}
44158
44164
  processedContent = processedContent.replace(/(import\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
44159
44165
  processedContent = processedContent.replace(/(import\(\s*['"])([^'"]+)(['"]\s*\))/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
44160
44166
  processedContent = processedContent.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path2) => {
44161
- if (!path2.match(/\.(js|ts|mjs|cjs)$/)) {
44162
- return `from ${quote}${path2}.js${quote}`;
44163
- }
44164
- if (path2.endsWith(".ts")) {
44165
- return `from ${quote}${path2.replace(/\.ts$/, ".js")}${quote}`;
44167
+ const rewritten = rewriteRelativeJsSpecifier(outputPath, path2);
44168
+ if (rewritten !== path2) {
44169
+ return `from ${quote}${rewritten}${quote}`;
44166
44170
  }
44167
44171
  return match;
44168
44172
  });
@@ -44256,11 +44260,12 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
44256
44260
  const compiledRoot = compiledParent;
44257
44261
  const indexesDir = join15(compiledParent, "indexes");
44258
44262
  await fs2.mkdir(indexesDir, { recursive: true });
44263
+ const aotOutputs = hmr ? [] : await compileAngularFiles(entryPoints.map((entry) => resolve16(entry)), compiledRoot, stylePreprocessors);
44259
44264
  const compileTasks = entryPoints.map(async (entry) => {
44260
44265
  const resolvedEntry = resolve16(entry);
44261
44266
  const relativeEntry = relative9(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
44262
- const compileEntry = () => hmr ? compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors) : compileAngularFile(resolvedEntry, compiledRoot, stylePreprocessors);
44263
- let outputs = await compileEntry();
44267
+ const compileEntry = () => compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors);
44268
+ let outputs = hmr ? await compileEntry() : aotOutputs;
44264
44269
  const fileBase = basename6(resolvedEntry).replace(/\.[tj]s$/, "");
44265
44270
  const jsName = `${fileBase}.js`;
44266
44271
  const compiledFallbackPaths = [
@@ -44287,7 +44292,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
44287
44292
  rawServerFile = resolveRawServerFile([]);
44288
44293
  }
44289
44294
  if (rawServerFile && !existsSync16(rawServerFile)) {
44290
- outputs = await compileEntry();
44295
+ outputs = hmr ? await compileEntry() : aotOutputs;
44291
44296
  rawServerFile = resolveRawServerFile(outputs);
44292
44297
  }
44293
44298
  if (!rawServerFile || !existsSync16(rawServerFile)) {
@@ -50100,5 +50105,5 @@ export {
50100
50105
  build
50101
50106
  };
50102
50107
 
50103
- //# debugId=B7727BFCF3CDC2DE64756E2164756E21
50108
+ //# debugId=366BD10A28027E4564756E2164756E21
50104
50109
  //# sourceMappingURL=build.js.map