@absolutejs/absolute 0.19.0-beta.755 → 0.19.0-beta.757

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
@@ -43505,15 +43505,7 @@ __export(exports_compileAngular, {
43505
43505
  import { existsSync as existsSync16, readFileSync as readFileSync9, promises as fs2 } from "fs";
43506
43506
  import { join as join15, basename as basename6, sep as sep3, dirname as dirname10, resolve as resolve16, relative as relative9 } from "path";
43507
43507
  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 = () => {
43508
+ var readTsconfigPathAliases = () => {
43517
43509
  try {
43518
43510
  const configPath2 = resolve16(process.cwd(), "tsconfig.json");
43519
43511
  const config = ts2.readConfigFile(configPath2, ts2.sys.readFile).config;
@@ -43664,6 +43656,21 @@ ${registrations}
43664
43656
  if (fileName.startsWith(outDir))
43665
43657
  return fileName.substring(outDir.length + 1);
43666
43658
  return fileName;
43659
+ }, hasJsLikeExtension = (path2) => /\.(js|ts|mjs|cjs)$/.test(path2), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
43660
+ if (specifier.endsWith(".ts"))
43661
+ return specifier.replace(/\.ts$/, ".js");
43662
+ if (hasJsLikeExtension(specifier))
43663
+ return specifier;
43664
+ const importerDir = dirname10(importerOutputPath);
43665
+ const fileCandidate = resolve16(importerDir, `${specifier}.js`);
43666
+ if (outputFiles?.has(fileCandidate) || existsSync16(fileCandidate)) {
43667
+ return `${specifier}.js`;
43668
+ }
43669
+ const indexCandidate = resolve16(importerDir, specifier, "index.js");
43670
+ if (outputFiles?.has(indexCandidate) || existsSync16(indexCandidate)) {
43671
+ return `${specifier}/index.js`;
43672
+ }
43673
+ return `${specifier}.js`;
43667
43674
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
43668
43675
  const sourceFile = ts2.createSourceFile(fileName, source, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
43669
43676
  const specifiers = [];
@@ -43729,65 +43736,48 @@ ${registrations}
43729
43736
  }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
43730
43737
  const islandMetadataExports = buildIslandMetadataExports(readFileSync9(inputPath, "utf-8"));
43731
43738
  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
- }
43739
+ const tsPath = __require.resolve("typescript");
43740
+ const tsRootDir = dirname10(tsPath);
43741
+ const tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve16(tsRootDir, "lib");
43742
+ const config = readConfiguration("./tsconfig.json");
43743
+ const options = {
43744
+ emitDecoratorMetadata: true,
43745
+ esModuleInterop: true,
43746
+ experimentalDecorators: true,
43747
+ module: ts2.ModuleKind.ESNext,
43748
+ moduleResolution: ts2.ModuleResolutionKind.Bundler,
43749
+ newLine: ts2.NewLineKind.LineFeed,
43750
+ noLib: false,
43751
+ outDir,
43752
+ skipLibCheck: true,
43753
+ target: ts2.ScriptTarget.ES2022,
43754
+ ...config.options
43755
+ };
43756
+ options.target = ts2.ScriptTarget.ES2022;
43757
+ options.experimentalDecorators = true;
43758
+ options.emitDecoratorMetadata = true;
43759
+ options.newLine = ts2.NewLineKind.LineFeed;
43760
+ options.outDir = outDir;
43761
+ options.noEmit = false;
43762
+ options.incremental = false;
43763
+ options.tsBuildInfoFile = undefined;
43764
+ options.rootDir = process.cwd();
43765
+ const host = ts2.createCompilerHost(options);
43766
+ const originalGetDefaultLibLocation = host.getDefaultLibLocation;
43767
+ host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
43768
+ const originalGetDefaultLibFileName = host.getDefaultLibFileName;
43769
+ host.getDefaultLibFileName = (opts) => {
43770
+ const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
43771
+ return basename6(fileName);
43772
+ };
43773
+ const originalGetSourceFile = host.getSourceFile;
43774
+ host.getSourceFile = (fileName, languageVersion, onError2) => {
43775
+ if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
43776
+ const resolvedPath = join15(tsLibDir, fileName);
43777
+ return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError2);
43778
+ }
43779
+ return originalGetSourceFile?.call(host, fileName, languageVersion, onError2);
43780
+ };
43791
43781
  const emitted = {};
43792
43782
  const resolvedOutDir = resolve16(outDir);
43793
43783
  host.writeFile = (fileName, text) => {
@@ -43827,11 +43817,16 @@ ${registrations}
43827
43817
  host.getSourceFile = originalGetSourceFileForCompile;
43828
43818
  }
43829
43819
  throwOnCompilationErrors(diagnostics);
43830
- const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
43831
- const target = join15(outDir, fileName);
43820
+ const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
43821
+ content,
43822
+ target: join15(outDir, fileName)
43823
+ }));
43824
+ const outputFiles = new Set(rawEntries.map(({ target }) => resolve16(target)));
43825
+ const entries = rawEntries.map(({ content, target }) => {
43832
43826
  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}`;
43827
+ const rewritten = rewriteRelativeJsSpecifier(target, path2, outputFiles);
43828
+ if (rewritten !== path2) {
43829
+ return `from ${quote}${rewritten}${quote}`;
43835
43830
  }
43836
43831
  return match;
43837
43832
  });
@@ -44144,6 +44139,7 @@ ${fields}
44144
44139
  };
44145
44140
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
44146
44141
  let processedContent = angularTranspiler.transformSync(sourceCode);
44142
+ const outputPath = toOutputPath(actualPath);
44147
44143
  const rewriteBareImport = (prefix, specifier, suffix) => {
44148
44144
  const rewritten = importRewrites.get(specifier);
44149
44145
  if (rewritten) {
@@ -44158,11 +44154,9 @@ ${fields}
44158
44154
  processedContent = processedContent.replace(/(import\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
44159
44155
  processedContent = processedContent.replace(/(import\(\s*['"])([^'"]+)(['"]\s*\))/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
44160
44156
  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}`;
44157
+ const rewritten = rewriteRelativeJsSpecifier(outputPath, path2);
44158
+ if (rewritten !== path2) {
44159
+ return `from ${quote}${rewritten}${quote}`;
44166
44160
  }
44167
44161
  return match;
44168
44162
  });
@@ -50100,5 +50094,5 @@ export {
50100
50094
  build
50101
50095
  };
50102
50096
 
50103
- //# debugId=B7727BFCF3CDC2DE64756E2164756E21
50097
+ //# debugId=0C2C32C1A62639B364756E2164756E21
50104
50098
  //# sourceMappingURL=build.js.map