@absolutejs/absolute 0.19.0-beta.756 → 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/index.js CHANGED
@@ -43697,15 +43697,7 @@ __export(exports_compileAngular, {
43697
43697
  import { existsSync as existsSync16, readFileSync as readFileSync10, promises as fs2 } from "fs";
43698
43698
  import { join as join15, basename as basename7, sep as sep3, dirname as dirname11, resolve as resolve19, relative as relative9 } from "path";
43699
43699
  import ts2 from "typescript";
43700
- import { createHash as createHash2 } from "crypto";
43701
- var computeConfigHash = () => {
43702
- try {
43703
- const content = readFileSync10("./tsconfig.json", "utf-8");
43704
- return createHash2("md5").update(content).digest("hex");
43705
- } catch {
43706
- return "";
43707
- }
43708
- }, readTsconfigPathAliases = () => {
43700
+ var readTsconfigPathAliases = () => {
43709
43701
  try {
43710
43702
  const configPath2 = resolve19(process.cwd(), "tsconfig.json");
43711
43703
  const config = ts2.readConfigFile(configPath2, ts2.sys.readFile).config;
@@ -43856,6 +43848,21 @@ ${registrations}
43856
43848
  if (fileName.startsWith(outDir))
43857
43849
  return fileName.substring(outDir.length + 1);
43858
43850
  return fileName;
43851
+ }, hasJsLikeExtension = (path2) => /\.(js|ts|mjs|cjs)$/.test(path2), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
43852
+ if (specifier.endsWith(".ts"))
43853
+ return specifier.replace(/\.ts$/, ".js");
43854
+ if (hasJsLikeExtension(specifier))
43855
+ return specifier;
43856
+ const importerDir = dirname11(importerOutputPath);
43857
+ const fileCandidate = resolve19(importerDir, `${specifier}.js`);
43858
+ if (outputFiles?.has(fileCandidate) || existsSync16(fileCandidate)) {
43859
+ return `${specifier}.js`;
43860
+ }
43861
+ const indexCandidate = resolve19(importerDir, specifier, "index.js");
43862
+ if (outputFiles?.has(indexCandidate) || existsSync16(indexCandidate)) {
43863
+ return `${specifier}/index.js`;
43864
+ }
43865
+ return `${specifier}.js`;
43859
43866
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
43860
43867
  const sourceFile = ts2.createSourceFile(fileName, source, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
43861
43868
  const specifiers = [];
@@ -43921,65 +43928,48 @@ ${registrations}
43921
43928
  }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
43922
43929
  const islandMetadataExports = buildIslandMetadataExports(readFileSync10(inputPath, "utf-8"));
43923
43930
  const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
43924
- const configHash = computeConfigHash();
43925
- const cached = globalThis.__angularCompilerCache;
43926
- let host;
43927
- let options;
43928
- let tsLibDir;
43929
- if (cached && cached.configHash === configHash) {
43930
- ({ host } = cached);
43931
- options = { ...cached.options, outDir, rootDir: process.cwd() };
43932
- ({ tsLibDir } = cached);
43933
- cached.lastUsed = Date.now();
43934
- } else {
43935
- const tsPath = __require.resolve("typescript");
43936
- const tsRootDir = dirname11(tsPath);
43937
- tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve19(tsRootDir, "lib");
43938
- const config = readConfiguration("./tsconfig.json");
43939
- options = {
43940
- emitDecoratorMetadata: true,
43941
- esModuleInterop: true,
43942
- experimentalDecorators: true,
43943
- module: ts2.ModuleKind.ESNext,
43944
- moduleResolution: ts2.ModuleResolutionKind.Bundler,
43945
- newLine: ts2.NewLineKind.LineFeed,
43946
- noLib: false,
43947
- outDir,
43948
- skipLibCheck: true,
43949
- target: ts2.ScriptTarget.ES2022,
43950
- ...config.options
43951
- };
43952
- options.target = ts2.ScriptTarget.ES2022;
43953
- options.experimentalDecorators = true;
43954
- options.emitDecoratorMetadata = true;
43955
- options.newLine = ts2.NewLineKind.LineFeed;
43956
- options.outDir = outDir;
43957
- options.noEmit = false;
43958
- options.rootDir = process.cwd();
43959
- host = ts2.createCompilerHost(options);
43960
- const originalGetDefaultLibLocation = host.getDefaultLibLocation;
43961
- host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
43962
- const originalGetDefaultLibFileName = host.getDefaultLibFileName;
43963
- host.getDefaultLibFileName = (opts) => {
43964
- const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
43965
- return basename7(fileName);
43966
- };
43967
- const originalGetSourceFile = host.getSourceFile;
43968
- host.getSourceFile = (fileName, languageVersion, onError2) => {
43969
- if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
43970
- const resolvedPath = join15(tsLibDir, fileName);
43971
- return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError2);
43972
- }
43973
- return originalGetSourceFile?.call(host, fileName, languageVersion, onError2);
43974
- };
43975
- globalThis.__angularCompilerCache = {
43976
- configHash,
43977
- host,
43978
- lastUsed: Date.now(),
43979
- options: { ...options },
43980
- tsLibDir
43981
- };
43982
- }
43931
+ const tsPath = __require.resolve("typescript");
43932
+ const tsRootDir = dirname11(tsPath);
43933
+ const tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve19(tsRootDir, "lib");
43934
+ const config = readConfiguration("./tsconfig.json");
43935
+ const options = {
43936
+ emitDecoratorMetadata: true,
43937
+ esModuleInterop: true,
43938
+ experimentalDecorators: true,
43939
+ module: ts2.ModuleKind.ESNext,
43940
+ moduleResolution: ts2.ModuleResolutionKind.Bundler,
43941
+ newLine: ts2.NewLineKind.LineFeed,
43942
+ noLib: false,
43943
+ outDir,
43944
+ skipLibCheck: true,
43945
+ target: ts2.ScriptTarget.ES2022,
43946
+ ...config.options
43947
+ };
43948
+ options.target = ts2.ScriptTarget.ES2022;
43949
+ options.experimentalDecorators = true;
43950
+ options.emitDecoratorMetadata = true;
43951
+ options.newLine = ts2.NewLineKind.LineFeed;
43952
+ options.outDir = outDir;
43953
+ options.noEmit = false;
43954
+ options.incremental = false;
43955
+ options.tsBuildInfoFile = undefined;
43956
+ options.rootDir = process.cwd();
43957
+ const host = ts2.createCompilerHost(options);
43958
+ const originalGetDefaultLibLocation = host.getDefaultLibLocation;
43959
+ host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
43960
+ const originalGetDefaultLibFileName = host.getDefaultLibFileName;
43961
+ host.getDefaultLibFileName = (opts) => {
43962
+ const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
43963
+ return basename7(fileName);
43964
+ };
43965
+ const originalGetSourceFile = host.getSourceFile;
43966
+ host.getSourceFile = (fileName, languageVersion, onError2) => {
43967
+ if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
43968
+ const resolvedPath = join15(tsLibDir, fileName);
43969
+ return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError2);
43970
+ }
43971
+ return originalGetSourceFile?.call(host, fileName, languageVersion, onError2);
43972
+ };
43983
43973
  const emitted = {};
43984
43974
  const resolvedOutDir = resolve19(outDir);
43985
43975
  host.writeFile = (fileName, text) => {
@@ -44019,11 +44009,16 @@ ${registrations}
44019
44009
  host.getSourceFile = originalGetSourceFileForCompile;
44020
44010
  }
44021
44011
  throwOnCompilationErrors(diagnostics);
44022
- const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
44023
- const target = join15(outDir, fileName);
44012
+ const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
44013
+ content,
44014
+ target: join15(outDir, fileName)
44015
+ }));
44016
+ const outputFiles = new Set(rawEntries.map(({ target }) => resolve19(target)));
44017
+ const entries = rawEntries.map(({ content, target }) => {
44024
44018
  let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path2) => {
44025
- if (!path2.match(/\.(js|ts|mjs|cjs)$/)) {
44026
- return `from ${quote}${path2}.js${quote}`;
44019
+ const rewritten = rewriteRelativeJsSpecifier(target, path2, outputFiles);
44020
+ if (rewritten !== path2) {
44021
+ return `from ${quote}${rewritten}${quote}`;
44027
44022
  }
44028
44023
  return match;
44029
44024
  });
@@ -44336,6 +44331,7 @@ ${fields}
44336
44331
  };
44337
44332
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
44338
44333
  let processedContent = angularTranspiler.transformSync(sourceCode);
44334
+ const outputPath = toOutputPath(actualPath);
44339
44335
  const rewriteBareImport = (prefix, specifier, suffix) => {
44340
44336
  const rewritten = importRewrites.get(specifier);
44341
44337
  if (rewritten) {
@@ -44350,11 +44346,9 @@ ${fields}
44350
44346
  processedContent = processedContent.replace(/(import\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
44351
44347
  processedContent = processedContent.replace(/(import\(\s*['"])([^'"]+)(['"]\s*\))/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
44352
44348
  processedContent = processedContent.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path2) => {
44353
- if (!path2.match(/\.(js|ts|mjs|cjs)$/)) {
44354
- return `from ${quote}${path2}.js${quote}`;
44355
- }
44356
- if (path2.endsWith(".ts")) {
44357
- return `from ${quote}${path2.replace(/\.ts$/, ".js")}${quote}`;
44349
+ const rewritten = rewriteRelativeJsSpecifier(outputPath, path2);
44350
+ if (rewritten !== path2) {
44351
+ return `from ${quote}${rewritten}${quote}`;
44358
44352
  }
44359
44353
  return match;
44360
44354
  });
@@ -58560,5 +58554,5 @@ export {
58560
58554
  ANGULAR_INIT_TIMEOUT_MS
58561
58555
  };
58562
58556
 
58563
- //# debugId=101D5DB96668BF8564756E2164756E21
58557
+ //# debugId=CB154A938111A9E864756E2164756E21
58564
58558
  //# sourceMappingURL=index.js.map