@aerobuilt/core 0.2.10 → 0.3.0
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-script-analysis-Bd9EyItC.mjs +193 -0
- package/dist/{entry-dev.d.ts → entry-dev.d.mts} +6 -16
- package/dist/entry-dev.mjs +127 -0
- package/dist/{entry-editor.d.ts → entry-editor.d.mts} +24 -22
- package/dist/entry-editor.mjs +3 -0
- package/dist/entry-prod.d.mts +10 -0
- package/dist/entry-prod.mjs +15 -0
- package/dist/routing-Bai79LCq.mjs +198 -0
- package/dist/runtime/index.d.mts +65 -0
- package/dist/runtime/index.mjs +207 -0
- package/dist/runtime/instance.d.mts +19 -0
- package/dist/runtime/instance.mjs +45 -0
- package/dist/types-CLHGhnGA.d.mts +209 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utils/aliases.d.mts +38 -0
- package/dist/utils/aliases.mjs +117 -0
- package/dist/utils/{redirects.d.ts → redirects.d.mts} +7 -12
- package/dist/utils/redirects.mjs +21 -0
- package/dist/vite/{index.d.ts → index.d.mts} +5 -12
- package/dist/vite/index.mjs +1890 -0
- package/package.json +25 -20
- package/dist/chunk-4DAK56WB.js +0 -36
- package/dist/chunk-5ZNUGZOW.js +0 -238
- package/dist/chunk-F7MXQXLM.js +0 -15
- package/dist/chunk-JAMYN2VX.js +0 -133
- package/dist/chunk-VTEG2UU3.js +0 -184
- package/dist/entry-dev.js +0 -101
- package/dist/entry-editor.js +0 -14
- package/dist/entry-prod.d.ts +0 -19
- package/dist/entry-prod.js +0 -19
- package/dist/runtime/index.d.ts +0 -74
- package/dist/runtime/index.js +0 -7
- package/dist/runtime/instance.d.ts +0 -31
- package/dist/runtime/instance.js +0 -10
- package/dist/types.d.ts +0 -202
- package/dist/types.js +0 -0
- package/dist/utils/redirects.js +0 -6
- package/dist/vite/index.js +0 -1991
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { getTsconfig } from "get-tsconfig";
|
|
3
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/aliases.ts
|
|
6
|
+
/** Shared oxc-resolver instance for Aero resolution (tsconfig auto, ESM, .html support). */
|
|
7
|
+
const resolver = new ResolverFactory({
|
|
8
|
+
extensions: [
|
|
9
|
+
".html",
|
|
10
|
+
".ts",
|
|
11
|
+
".js",
|
|
12
|
+
".json",
|
|
13
|
+
".node"
|
|
14
|
+
],
|
|
15
|
+
conditionNames: ["node", "import"],
|
|
16
|
+
tsconfig: "auto"
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Build default path aliases for @pages, @layouts, @components from project root and dirs.
|
|
20
|
+
* Used when tsconfig is missing or does not define these keys so the runtime globs resolve.
|
|
21
|
+
*/
|
|
22
|
+
function getDefaultAliases(root, dirs) {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
find: "@pages",
|
|
26
|
+
replacement: path.join(root, dirs.client, "pages")
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
find: "@layouts",
|
|
30
|
+
replacement: path.join(root, dirs.client, "layouts")
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
find: "@components",
|
|
34
|
+
replacement: path.join(root, dirs.client, "components")
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Load path aliases from tsconfig.json at or above the given root.
|
|
40
|
+
*
|
|
41
|
+
* @param root - Project root directory (e.g. `process.cwd()` or Vite config root).
|
|
42
|
+
* @returns AliasResult with `aliases` for Vite resolve.alias and `resolve(specifier, importer)` for compiler/build.
|
|
43
|
+
*/
|
|
44
|
+
function loadTsconfigAliases(root) {
|
|
45
|
+
const result = getTsconfig(root);
|
|
46
|
+
if (!result) return {
|
|
47
|
+
aliases: [],
|
|
48
|
+
resolve: (specifier, importer) => {
|
|
49
|
+
return resolver.resolveFileSync(importer, specifier)?.path ?? specifier;
|
|
50
|
+
},
|
|
51
|
+
projectRoot: void 0
|
|
52
|
+
};
|
|
53
|
+
const options = result.config.compilerOptions;
|
|
54
|
+
const paths = options?.paths || {};
|
|
55
|
+
const baseUrl = options?.baseUrl || ".";
|
|
56
|
+
const configDir = path.dirname(result.path || root);
|
|
57
|
+
const baseDir = path.resolve(configDir, baseUrl);
|
|
58
|
+
const projectRoot = configDir;
|
|
59
|
+
const aliases = [];
|
|
60
|
+
for (const [key, values] of Object.entries(paths)) {
|
|
61
|
+
const first = Array.from(values)[0];
|
|
62
|
+
if (typeof first !== "string" || first.length === 0) continue;
|
|
63
|
+
const find = key.replace(/\/*$/, "").replace("/*", "");
|
|
64
|
+
const target = first.replace(/\/*$/, "").replace("/*", "");
|
|
65
|
+
const replacement = path.resolve(baseDir, target);
|
|
66
|
+
aliases.push({
|
|
67
|
+
find,
|
|
68
|
+
replacement
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** Resolve specifier from importer using oxc-resolver (tsconfig paths, extensions, package exports). */
|
|
72
|
+
const resolve = (specifier, importer) => {
|
|
73
|
+
return resolver.resolveFileSync(importer, specifier)?.path ?? specifier;
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
aliases,
|
|
77
|
+
resolve,
|
|
78
|
+
projectRoot
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Merge framework default aliases (from dirs) with tsconfig-derived aliases.
|
|
83
|
+
* Defaults are applied first; any alias from aliasResult with the same `find` overwrites.
|
|
84
|
+
* Produces a resolve that tries merged aliases first, then falls back to the original resolver.
|
|
85
|
+
*
|
|
86
|
+
* Ensures @pages, @layouts, @components always exist so the runtime import.meta.glob patterns resolve.
|
|
87
|
+
*
|
|
88
|
+
* @param aliasResult - Result from loadTsconfigAliases (may have empty aliases when no tsconfig).
|
|
89
|
+
* @param root - Project root.
|
|
90
|
+
* @param dirs - Resolved client/layouts/components dirs.
|
|
91
|
+
* @returns AliasResult with merged aliases and a resolve that uses them.
|
|
92
|
+
*/
|
|
93
|
+
function mergeWithDefaultAliases(aliasResult, root, dirs) {
|
|
94
|
+
const defaults = getDefaultAliases(root, dirs);
|
|
95
|
+
const byFind = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const a of defaults) byFind.set(a.find, a.replacement);
|
|
97
|
+
for (const a of aliasResult.aliases) byFind.set(a.find, a.replacement);
|
|
98
|
+
const aliases = Array.from(byFind.entries()).map(([find, replacement]) => ({
|
|
99
|
+
find,
|
|
100
|
+
replacement
|
|
101
|
+
}));
|
|
102
|
+
const resolve = (specifier, importer) => {
|
|
103
|
+
for (const { find, replacement } of aliases) if (specifier === find || specifier.startsWith(find + "/")) {
|
|
104
|
+
const rest = specifier.slice(find.length);
|
|
105
|
+
return path.join(replacement, rest.replace(/^\//, ""));
|
|
106
|
+
}
|
|
107
|
+
return aliasResult.resolve(specifier, importer);
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
aliases,
|
|
111
|
+
resolve,
|
|
112
|
+
projectRoot: aliasResult.projectRoot
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
export { getDefaultAliases, loadTsconfigAliases, mergeWithDefaultAliases };
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { RedirectRule } from
|
|
2
|
-
import 'vite';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Convert Aero redirect rules to Nitro routeRules.
|
|
6
|
-
* Used when generating Nitro config from Aero options (no project nitro.config.ts).
|
|
7
|
-
*/
|
|
1
|
+
import { m as RedirectRule } from "../types-CLHGhnGA.mjs";
|
|
8
2
|
|
|
3
|
+
//#region src/utils/redirects.d.ts
|
|
9
4
|
/** Nitro routeRules redirect value: shorthand (307) or object with statusCode. */
|
|
10
5
|
type NitroRedirectRule = string | {
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
to: string;
|
|
7
|
+
statusCode: number;
|
|
13
8
|
};
|
|
14
9
|
/**
|
|
15
10
|
* Map redirect rules to Nitro's routeRules shape.
|
|
@@ -18,7 +13,7 @@ type NitroRedirectRule = string | {
|
|
|
18
13
|
* @returns Record suitable for Nitro's routeRules.
|
|
19
14
|
*/
|
|
20
15
|
declare function redirectsToRouteRules(redirects: RedirectRule[]): Record<string, {
|
|
21
|
-
|
|
16
|
+
redirect: NitroRedirectRule;
|
|
22
17
|
}>;
|
|
23
|
-
|
|
24
|
-
export { redirectsToRouteRules };
|
|
18
|
+
//#endregion
|
|
19
|
+
export { redirectsToRouteRules };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/utils/redirects.ts
|
|
2
|
+
/**
|
|
3
|
+
* Map redirect rules to Nitro's routeRules shape.
|
|
4
|
+
*
|
|
5
|
+
* @param redirects - Array of { from, to, status? } from aero config.
|
|
6
|
+
* @returns Record suitable for Nitro's routeRules.
|
|
7
|
+
*/
|
|
8
|
+
function redirectsToRouteRules(redirects) {
|
|
9
|
+
const out = {};
|
|
10
|
+
for (const rule of redirects) {
|
|
11
|
+
const status = rule.status ?? 302;
|
|
12
|
+
out[rule.from] = { redirect: status === 307 ? rule.to : {
|
|
13
|
+
to: rule.to,
|
|
14
|
+
statusCode: status
|
|
15
|
+
} };
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { redirectsToRouteRules };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { AeroOptions } from
|
|
2
|
-
import { PluginOption } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Aero Vite plugin: HTML transform, virtual modules, dev server middleware, and static build.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Split into focused sub-plugins: config, virtuals (resolve/load), transform, SSR middleware.
|
|
9
|
-
* Static build plugin runs after closeBundle; Nitro and image optimizer are composed in the factory.
|
|
10
|
-
*/
|
|
1
|
+
import { i as AeroOptions } from "../types-CLHGhnGA.mjs";
|
|
2
|
+
import { PluginOption } from "vite";
|
|
11
3
|
|
|
4
|
+
//#region src/vite/index.d.ts
|
|
12
5
|
/**
|
|
13
6
|
* Aero Vite plugin factory. Returns an array of plugins: config, virtuals, transform, SSR,
|
|
14
7
|
* static-build, image optimizer, and optionally Nitro (serve only).
|
|
@@ -19,5 +12,5 @@ import { PluginOption } from 'vite';
|
|
|
19
12
|
* @returns PluginOption[] to pass to Vite's plugins array.
|
|
20
13
|
*/
|
|
21
14
|
declare function aero(options?: AeroOptions): PluginOption[];
|
|
22
|
-
|
|
23
|
-
export { aero };
|
|
15
|
+
//#endregion
|
|
16
|
+
export { aero };
|