@akanjs/devkit 2.1.0-rc.2 → 2.1.0-rc.3
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.
|
@@ -24,9 +24,9 @@ export class CssImportResolver {
|
|
|
24
24
|
|
|
25
25
|
async resolve(id: string, fromBase: string): Promise<string | null> {
|
|
26
26
|
for (const resolve of [
|
|
27
|
+
() => this.#resolveWithTsconfig(id),
|
|
27
28
|
() => this.#resolveWithBun(id, fromBase),
|
|
28
29
|
() => this.#resolveWithRequire(id, fromBase),
|
|
29
|
-
() => this.#resolveWithTsconfig(id),
|
|
30
30
|
() => this.#resolvePackageStyle(id, fromBase),
|
|
31
31
|
]) {
|
|
32
32
|
const resolved = await resolve();
|
|
@@ -36,21 +36,27 @@ export class CssImportResolver {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
#resolveWithBun(id: string, fromBase: string): string | null {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
for (const base of this.#resolutionBases(fromBase)) {
|
|
40
|
+
try {
|
|
41
|
+
const resolved = Bun.resolveSync(id, base);
|
|
42
|
+
if (CssImportResolver.isCssFile(resolved)) return resolved;
|
|
43
|
+
} catch {
|
|
44
|
+
// Try the next known package resolution root.
|
|
45
|
+
}
|
|
44
46
|
}
|
|
47
|
+
return null;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
#resolveWithRequire(id: string, fromBase: string): string | null {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
for (const base of this.#resolutionBases(fromBase)) {
|
|
52
|
+
try {
|
|
53
|
+
const resolved = require.resolve(id, { paths: [base] });
|
|
54
|
+
if (CssImportResolver.isCssFile(resolved)) return resolved;
|
|
55
|
+
} catch {
|
|
56
|
+
// Try the next known package resolution root.
|
|
57
|
+
}
|
|
53
58
|
}
|
|
59
|
+
return null;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
async #resolveWithTsconfig(id: string): Promise<string | null> {
|
|
@@ -77,8 +83,25 @@ export class CssImportResolver {
|
|
|
77
83
|
async #resolvePackageStyle(id: string, fromBase: string): Promise<string | null> {
|
|
78
84
|
const pkgName = CssImportResolver.getPackageName(id);
|
|
79
85
|
if (!pkgName) return null;
|
|
86
|
+
for (const base of this.#resolutionBases(fromBase)) {
|
|
87
|
+
try {
|
|
88
|
+
const pkgPath = require.resolve(`${pkgName}/package.json`, { paths: [base] });
|
|
89
|
+
const resolved = await this.#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath);
|
|
90
|
+
if (resolved) return resolved;
|
|
91
|
+
} catch {
|
|
92
|
+
// Try the next known package resolution root.
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const pkgPath of this.#packageJsonCandidates(pkgName)) {
|
|
96
|
+
const resolved = await this.#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath);
|
|
97
|
+
if (resolved) return resolved;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async #resolvePackageStyleFromPackageJson(id: string, pkgName: string, pkgPath: string): Promise<string | null> {
|
|
80
103
|
try {
|
|
81
|
-
|
|
104
|
+
if (!(await Bun.file(pkgPath).exists())) return null;
|
|
82
105
|
const pkgDir = path.dirname(pkgPath);
|
|
83
106
|
const pkg = await Bun.file(pkgPath).json();
|
|
84
107
|
const subpath = id === pkgName ? "." : `.${id.slice(pkgName.length)}`;
|
|
@@ -96,6 +119,24 @@ export class CssImportResolver {
|
|
|
96
119
|
}
|
|
97
120
|
}
|
|
98
121
|
|
|
122
|
+
#resolutionBases(fromBase: string): string[] {
|
|
123
|
+
return [
|
|
124
|
+
fromBase,
|
|
125
|
+
this.#workspaceRoot,
|
|
126
|
+
path.dirname(Bun.main),
|
|
127
|
+
path.resolve(path.dirname(Bun.main), "../.."),
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#packageJsonCandidates(pkgName: string): string[] {
|
|
132
|
+
return [
|
|
133
|
+
path.join(this.#workspaceRoot, "pkgs", pkgName, "package.json"),
|
|
134
|
+
path.join(this.#workspaceRoot, "node_modules", pkgName, "package.json"),
|
|
135
|
+
path.join(path.dirname(Bun.main), "node_modules", pkgName, "package.json"),
|
|
136
|
+
path.join(path.dirname(Bun.main), "../../", pkgName, "package.json"),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
|
|
99
140
|
async #firstExisting(basePath: string): Promise<string | null> {
|
|
100
141
|
for (const suffix of CSS_IMPORT_EXTS) {
|
|
101
142
|
const candidate = `${basePath}${suffix}`;
|
|
@@ -94,13 +94,26 @@ export class SsrBaseArtifactBuilder {
|
|
|
94
94
|
async #resolveAkanServerPath() {
|
|
95
95
|
const candidates = [
|
|
96
96
|
path.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"),
|
|
97
|
+
path.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"),
|
|
98
|
+
path.join(path.dirname(Bun.main), "node_modules/akanjs/server"),
|
|
99
|
+
path.join(path.dirname(Bun.main), "../../akanjs/server"),
|
|
97
100
|
path.resolve(import.meta.dir, "../../server"),
|
|
98
101
|
path.resolve(import.meta.dir, "../server"),
|
|
99
102
|
];
|
|
103
|
+
try {
|
|
104
|
+
candidates.unshift(path.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
|
|
105
|
+
} catch {
|
|
106
|
+
// Source workspaces and bundled CLI execution have different resolution roots; try the explicit candidates.
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
candidates.unshift(path.dirname(Bun.resolveSync("akanjs/server", path.dirname(Bun.main))));
|
|
110
|
+
} catch {
|
|
111
|
+
// Published CLI installs may hoist dependencies differently; explicit Bun.main candidates cover that.
|
|
112
|
+
}
|
|
100
113
|
for (const candidate of candidates) {
|
|
101
114
|
if (await Bun.file(path.join(candidate, "rscClient.tsx")).exists()) return candidate;
|
|
102
115
|
}
|
|
103
|
-
|
|
116
|
+
throw new Error(`[base-artifact] failed to locate akanjs/server; looked in: ${candidates.join(", ")}`);
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
async #buildStyleAssets(): Promise<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.3",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@langchain/deepseek": "^1.0.26",
|
|
37
37
|
"@langchain/openai": "^1.4.6",
|
|
38
38
|
"@trapezedev/project": "^7.1.4",
|
|
39
|
-
"akanjs": "2.1.0-rc.
|
|
39
|
+
"akanjs": "2.1.0-rc.3",
|
|
40
40
|
"chalk": "^5.6.2",
|
|
41
41
|
"commander": "^14.0.3",
|
|
42
42
|
"fontaine": "^0.8.0",
|