@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.
@@ -3226,15 +3226,7 @@ __export(exports_compileAngular, {
3226
3226
  import { existsSync as existsSync5, readFileSync as readFileSync4, promises as fs } from "fs";
3227
3227
  import { join as join5, basename as basename3, sep, dirname as dirname4, resolve as resolve6, relative as relative3 } from "path";
3228
3228
  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 = () => {
3229
+ var readTsconfigPathAliases = () => {
3238
3230
  try {
3239
3231
  const configPath = resolve6(process.cwd(), "tsconfig.json");
3240
3232
  const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
@@ -3385,6 +3377,21 @@ ${registrations}
3385
3377
  if (fileName.startsWith(outDir))
3386
3378
  return fileName.substring(outDir.length + 1);
3387
3379
  return fileName;
3380
+ }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
3381
+ if (specifier.endsWith(".ts"))
3382
+ return specifier.replace(/\.ts$/, ".js");
3383
+ if (hasJsLikeExtension(specifier))
3384
+ return specifier;
3385
+ const importerDir = dirname4(importerOutputPath);
3386
+ const fileCandidate = resolve6(importerDir, `${specifier}.js`);
3387
+ if (outputFiles?.has(fileCandidate) || existsSync5(fileCandidate)) {
3388
+ return `${specifier}.js`;
3389
+ }
3390
+ const indexCandidate = resolve6(importerDir, specifier, "index.js");
3391
+ if (outputFiles?.has(indexCandidate) || existsSync5(indexCandidate)) {
3392
+ return `${specifier}/index.js`;
3393
+ }
3394
+ return `${specifier}.js`;
3388
3395
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
3389
3396
  const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
3390
3397
  const specifiers = [];
@@ -3450,65 +3457,48 @@ ${registrations}
3450
3457
  }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
3451
3458
  const islandMetadataExports = buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"));
3452
3459
  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
- }
3460
+ const tsPath = __require.resolve("typescript");
3461
+ const tsRootDir = dirname4(tsPath);
3462
+ const tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve6(tsRootDir, "lib");
3463
+ const config = readConfiguration("./tsconfig.json");
3464
+ const options = {
3465
+ emitDecoratorMetadata: true,
3466
+ esModuleInterop: true,
3467
+ experimentalDecorators: true,
3468
+ module: ts.ModuleKind.ESNext,
3469
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
3470
+ newLine: ts.NewLineKind.LineFeed,
3471
+ noLib: false,
3472
+ outDir,
3473
+ skipLibCheck: true,
3474
+ target: ts.ScriptTarget.ES2022,
3475
+ ...config.options
3476
+ };
3477
+ options.target = ts.ScriptTarget.ES2022;
3478
+ options.experimentalDecorators = true;
3479
+ options.emitDecoratorMetadata = true;
3480
+ options.newLine = ts.NewLineKind.LineFeed;
3481
+ options.outDir = outDir;
3482
+ options.noEmit = false;
3483
+ options.incremental = false;
3484
+ options.tsBuildInfoFile = undefined;
3485
+ options.rootDir = process.cwd();
3486
+ const host = ts.createCompilerHost(options);
3487
+ const originalGetDefaultLibLocation = host.getDefaultLibLocation;
3488
+ host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
3489
+ const originalGetDefaultLibFileName = host.getDefaultLibFileName;
3490
+ host.getDefaultLibFileName = (opts) => {
3491
+ const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
3492
+ return basename3(fileName);
3493
+ };
3494
+ const originalGetSourceFile = host.getSourceFile;
3495
+ host.getSourceFile = (fileName, languageVersion, onError) => {
3496
+ if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
3497
+ const resolvedPath = join5(tsLibDir, fileName);
3498
+ return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
3499
+ }
3500
+ return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
3501
+ };
3512
3502
  const emitted = {};
3513
3503
  const resolvedOutDir = resolve6(outDir);
3514
3504
  host.writeFile = (fileName, text) => {
@@ -3548,11 +3538,16 @@ ${registrations}
3548
3538
  host.getSourceFile = originalGetSourceFileForCompile;
3549
3539
  }
3550
3540
  throwOnCompilationErrors(diagnostics);
3551
- const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
3552
- const target = join5(outDir, fileName);
3541
+ const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
3542
+ content,
3543
+ target: join5(outDir, fileName)
3544
+ }));
3545
+ const outputFiles = new Set(rawEntries.map(({ target }) => resolve6(target)));
3546
+ const entries = rawEntries.map(({ content, target }) => {
3553
3547
  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}`;
3548
+ const rewritten = rewriteRelativeJsSpecifier(target, path, outputFiles);
3549
+ if (rewritten !== path) {
3550
+ return `from ${quote}${rewritten}${quote}`;
3556
3551
  }
3557
3552
  return match;
3558
3553
  });
@@ -3865,6 +3860,7 @@ ${fields}
3865
3860
  };
3866
3861
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
3867
3862
  let processedContent = angularTranspiler.transformSync(sourceCode);
3863
+ const outputPath = toOutputPath(actualPath);
3868
3864
  const rewriteBareImport = (prefix, specifier, suffix) => {
3869
3865
  const rewritten = importRewrites.get(specifier);
3870
3866
  if (rewritten) {
@@ -3879,11 +3875,9 @@ ${fields}
3879
3875
  processedContent = processedContent.replace(/(import\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
3880
3876
  processedContent = processedContent.replace(/(import\(\s*['"])([^'"]+)(['"]\s*\))/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
3881
3877
  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}`;
3878
+ const rewritten = rewriteRelativeJsSpecifier(outputPath, path);
3879
+ if (rewritten !== path) {
3880
+ return `from ${quote}${rewritten}${quote}`;
3887
3881
  }
3888
3882
  return match;
3889
3883
  });
@@ -14773,5 +14767,5 @@ export {
14773
14767
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
14774
14768
  };
14775
14769
 
14776
- //# debugId=9D9C1F7007C6AC5764756E2164756E21
14770
+ //# debugId=272B12BE4516B59464756E2164756E21
14777
14771
  //# sourceMappingURL=index.js.map