@absolutejs/absolute 0.19.0-beta.696 → 0.19.0-beta.698
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/angular/index.js +91 -12
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +91 -12
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +92 -13
- package/dist/build.js.map +4 -4
- package/dist/cli/index.js +8 -1
- package/dist/index.js +92 -13
- package/dist/index.js.map +4 -4
- package/package.json +7 -7
package/dist/angular/index.js
CHANGED
|
@@ -3106,6 +3106,37 @@ var computeConfigHash = () => {
|
|
|
3106
3106
|
} catch {
|
|
3107
3107
|
return "";
|
|
3108
3108
|
}
|
|
3109
|
+
}, readTsconfigPathAliases = () => {
|
|
3110
|
+
try {
|
|
3111
|
+
const configPath = resolve6(process.cwd(), "tsconfig.json");
|
|
3112
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
|
|
3113
|
+
const compilerOptions = config?.compilerOptions ?? {};
|
|
3114
|
+
const baseUrl = resolve6(process.cwd(), compilerOptions.baseUrl ?? ".");
|
|
3115
|
+
const aliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, replacements]) => ({ pattern, replacements }));
|
|
3116
|
+
return { aliases, baseUrl };
|
|
3117
|
+
} catch {
|
|
3118
|
+
return { aliases: [], baseUrl: process.cwd() };
|
|
3119
|
+
}
|
|
3120
|
+
}, matchTsconfigAlias = (specifier, aliases, baseUrl, resolveSourceFile) => {
|
|
3121
|
+
for (const alias of aliases) {
|
|
3122
|
+
const wildcardIndex = alias.pattern.indexOf("*");
|
|
3123
|
+
const exactMatch = wildcardIndex === -1;
|
|
3124
|
+
if (exactMatch && specifier !== alias.pattern)
|
|
3125
|
+
continue;
|
|
3126
|
+
const prefix = exactMatch ? alias.pattern : alias.pattern.slice(0, wildcardIndex);
|
|
3127
|
+
const suffix = exactMatch ? "" : alias.pattern.slice(wildcardIndex + 1);
|
|
3128
|
+
if (!exactMatch && (!specifier.startsWith(prefix) || !specifier.endsWith(suffix))) {
|
|
3129
|
+
continue;
|
|
3130
|
+
}
|
|
3131
|
+
const wildcardValue = exactMatch ? "" : specifier.slice(prefix.length, specifier.length - suffix.length);
|
|
3132
|
+
for (const replacement of alias.replacements) {
|
|
3133
|
+
const candidate = replacement.replace("*", wildcardValue);
|
|
3134
|
+
const resolved = resolveSourceFile(resolve6(baseUrl, candidate));
|
|
3135
|
+
if (resolved)
|
|
3136
|
+
return resolved;
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
return;
|
|
3109
3140
|
}, resolveDevClientDir = () => {
|
|
3110
3141
|
const projectRoot = process.cwd();
|
|
3111
3142
|
const fromSource = resolve6(import.meta.dir, "../dev/client");
|
|
@@ -3584,9 +3615,52 @@ ${fields}
|
|
|
3584
3615
|
}
|
|
3585
3616
|
})
|
|
3586
3617
|
});
|
|
3587
|
-
const
|
|
3618
|
+
const tsconfigAliases = readTsconfigPathAliases();
|
|
3619
|
+
const resolveSourceFile = (candidate) => {
|
|
3620
|
+
const candidates = candidate.match(/\.[cm]?[tj]sx?$/) ? [candidate] : [
|
|
3621
|
+
`${candidate}.ts`,
|
|
3622
|
+
`${candidate}.tsx`,
|
|
3623
|
+
`${candidate}.js`,
|
|
3624
|
+
`${candidate}.jsx`,
|
|
3625
|
+
join5(candidate, "index.ts"),
|
|
3626
|
+
join5(candidate, "index.tsx"),
|
|
3627
|
+
join5(candidate, "index.js"),
|
|
3628
|
+
join5(candidate, "index.jsx")
|
|
3629
|
+
];
|
|
3630
|
+
return candidates.find((file) => existsSync5(file));
|
|
3631
|
+
};
|
|
3632
|
+
const resolveLocalImport = (specifier, fromDir) => {
|
|
3633
|
+
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3634
|
+
return resolveSourceFile(resolve6(fromDir, specifier));
|
|
3635
|
+
}
|
|
3636
|
+
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile);
|
|
3637
|
+
if (aliased)
|
|
3638
|
+
return aliased;
|
|
3639
|
+
try {
|
|
3640
|
+
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
3641
|
+
if (resolved.includes("/node_modules/"))
|
|
3642
|
+
return;
|
|
3643
|
+
const absolute = resolve6(resolved);
|
|
3644
|
+
if (!absolute.startsWith(baseDir))
|
|
3645
|
+
return;
|
|
3646
|
+
return resolveSourceFile(absolute);
|
|
3647
|
+
} catch {
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
};
|
|
3651
|
+
const toOutputPath = (sourcePath) => {
|
|
3652
|
+
const inputDir = dirname4(sourcePath);
|
|
3653
|
+
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
3654
|
+
const fileBase = basename3(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
3655
|
+
return join5(outDir, relativeDir, fileBase);
|
|
3656
|
+
};
|
|
3657
|
+
const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
|
|
3588
3658
|
let processedContent = angularTranspiler.transformSync(sourceCode);
|
|
3589
3659
|
const rewriteBareImport = (prefix, specifier, suffix) => {
|
|
3660
|
+
const rewritten = importRewrites.get(specifier);
|
|
3661
|
+
if (rewritten) {
|
|
3662
|
+
return `${prefix}${rewritten}${suffix}`;
|
|
3663
|
+
}
|
|
3590
3664
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3591
3665
|
return `${prefix}${specifier}${suffix}`;
|
|
3592
3666
|
}
|
|
@@ -3631,12 +3705,13 @@ ${fields}
|
|
|
3631
3705
|
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname4(actualPath)).source;
|
|
3632
3706
|
const inputDir = dirname4(actualPath);
|
|
3633
3707
|
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
3634
|
-
const fileBase = basename3(actualPath).replace(/\.
|
|
3708
|
+
const fileBase = basename3(actualPath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
3635
3709
|
const targetDir = join5(outDir, relativeDir);
|
|
3636
|
-
const targetPath =
|
|
3710
|
+
const targetPath = toOutputPath(actualPath);
|
|
3637
3711
|
const localImports = [];
|
|
3638
|
-
const
|
|
3639
|
-
const
|
|
3712
|
+
const importRewrites = new Map;
|
|
3713
|
+
const fromRegex = /(?:from|import)\s+['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]/g;
|
|
3714
|
+
const dynamicImportRegex = /import\(\s*['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]\s*\)/g;
|
|
3640
3715
|
let importMatch;
|
|
3641
3716
|
while ((importMatch = fromRegex.exec(sourceCode)) !== null) {
|
|
3642
3717
|
if (importMatch[1])
|
|
@@ -3646,22 +3721,26 @@ ${fields}
|
|
|
3646
3721
|
if (importMatch[1])
|
|
3647
3722
|
localImports.push(importMatch[1]);
|
|
3648
3723
|
}
|
|
3724
|
+
const localImportPaths = localImports.map((specifier) => {
|
|
3725
|
+
const resolved2 = resolveLocalImport(specifier, inputDir);
|
|
3726
|
+
if (!resolved2)
|
|
3727
|
+
return null;
|
|
3728
|
+
const relativeImport = relative3(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
|
|
3729
|
+
importRewrites.set(specifier, relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`);
|
|
3730
|
+
return resolved2;
|
|
3731
|
+
}).filter((path) => Boolean(path));
|
|
3649
3732
|
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
3650
3733
|
const cacheKey = actualPath;
|
|
3651
3734
|
if (jitContentCache.get(cacheKey) === contentHash && existsSync5(targetPath)) {
|
|
3652
3735
|
allOutputs.push(targetPath);
|
|
3653
3736
|
} else {
|
|
3654
|
-
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath);
|
|
3737
|
+
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
|
|
3655
3738
|
await fs.mkdir(targetDir, { recursive: true });
|
|
3656
3739
|
await fs.writeFile(targetPath, processedContent, "utf-8");
|
|
3657
3740
|
allOutputs.push(targetPath);
|
|
3658
3741
|
jitContentCache.set(cacheKey, contentHash);
|
|
3659
3742
|
}
|
|
3660
|
-
|
|
3661
|
-
await Promise.all(localImports.map((imp) => {
|
|
3662
|
-
const importPath = resolve6(inputDirForResolve, imp);
|
|
3663
|
-
return transpileFile(importPath);
|
|
3664
|
-
}));
|
|
3743
|
+
await Promise.all(localImportPaths.map((importPath) => transpileFile(importPath)));
|
|
3665
3744
|
};
|
|
3666
3745
|
await transpileFile(inputPath);
|
|
3667
3746
|
return allOutputs;
|
|
@@ -14136,5 +14215,5 @@ export {
|
|
|
14136
14215
|
Island
|
|
14137
14216
|
};
|
|
14138
14217
|
|
|
14139
|
-
//# debugId=
|
|
14218
|
+
//# debugId=119615262AC4E33764756E2164756E21
|
|
14140
14219
|
//# sourceMappingURL=index.js.map
|