@akanjs/devkit 2.3.10-rc.0 → 2.3.10-rc.2
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/executors.ts
CHANGED
|
@@ -437,8 +437,11 @@ export class Executor {
|
|
|
437
437
|
getPath(filePath: string) {
|
|
438
438
|
if (path.isAbsolute(filePath)) return filePath;
|
|
439
439
|
if (filePath.startsWith(".")) return path.join(this.cwdPath, filePath);
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
// Split on both separators so a Windows/mixed cwdPath (e.g. "C:\repo/apps/name") is parsed
|
|
441
|
+
// correctly, then rebuild with path.join so the result stays OS-native instead of the
|
|
442
|
+
// invalid "/C:\repo/..." the previous forward-slash-only reconstruction produced.
|
|
443
|
+
const baseParts = this.cwdPath.split(/[\\/]/).filter(Boolean);
|
|
444
|
+
const targetParts = filePath.split(/[\\/]/).filter(Boolean);
|
|
442
445
|
|
|
443
446
|
let overlapLength = 0;
|
|
444
447
|
for (let i = 1; i <= Math.min(baseParts.length, targetParts.length); i++) {
|
|
@@ -450,11 +453,7 @@ export class Executor {
|
|
|
450
453
|
}
|
|
451
454
|
if (isOverlap) overlapLength = i;
|
|
452
455
|
}
|
|
453
|
-
|
|
454
|
-
overlapLength > 0
|
|
455
|
-
? `/${[...baseParts, ...targetParts.slice(overlapLength)].join("/")}`
|
|
456
|
-
: `${this.cwdPath}/${filePath}`;
|
|
457
|
-
return result.replace(/\/+/g, "/");
|
|
456
|
+
return path.join(this.cwdPath, ...targetParts.slice(overlapLength));
|
|
458
457
|
}
|
|
459
458
|
async mkdir(dirPath: string) {
|
|
460
459
|
const writePath = this.getPath(dirPath);
|
|
@@ -33,17 +33,21 @@ afterEach(async () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
describe("PagesEntrySourceGenerator", () => {
|
|
36
|
-
|
|
36
|
+
const toSpecifier = (absPath: string) => path.resolve(absPath).split(path.sep).join("/");
|
|
37
|
+
|
|
38
|
+
test("generates dynamic import source using forward-slash module paths", () => {
|
|
39
|
+
const indexAbs = path.resolve("/repo/apps/demo/page/_index.tsx");
|
|
40
|
+
const adminAbs = path.resolve("/repo/apps/demo/page/admin.tsx");
|
|
37
41
|
const source = PagesEntrySourceGenerator.generate([
|
|
38
|
-
{ key: "./_index.tsx", moduleAbsPath:
|
|
39
|
-
{ key: "./admin.tsx", moduleAbsPath:
|
|
42
|
+
{ key: "./_index.tsx", moduleAbsPath: indexAbs },
|
|
43
|
+
{ key: "./admin.tsx", moduleAbsPath: adminAbs },
|
|
40
44
|
]);
|
|
41
45
|
|
|
42
46
|
expect(source).toBe(
|
|
43
47
|
[
|
|
44
48
|
"export const pages = {",
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
` "./_index.tsx": () => import(${JSON.stringify(toSpecifier(indexAbs))}),`,
|
|
50
|
+
` "./admin.tsx": () => import(${JSON.stringify(toSpecifier(adminAbs))}),`,
|
|
47
51
|
"};",
|
|
48
52
|
"",
|
|
49
53
|
].join("\n"),
|
|
@@ -51,15 +55,17 @@ describe("PagesEntrySourceGenerator", () => {
|
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
test("generates static import source for single-file CSR bundles", () => {
|
|
58
|
+
const indexAbs = path.resolve("/repo/apps/demo/page/_index.tsx");
|
|
59
|
+
const adminAbs = path.resolve("/repo/apps/demo/page/admin.tsx");
|
|
54
60
|
const source = PagesEntrySourceGenerator.generateStatic([
|
|
55
|
-
{ key: "./_index.tsx", moduleAbsPath:
|
|
56
|
-
{ key: "./admin.tsx", moduleAbsPath:
|
|
61
|
+
{ key: "./_index.tsx", moduleAbsPath: indexAbs },
|
|
62
|
+
{ key: "./admin.tsx", moduleAbsPath: adminAbs },
|
|
57
63
|
]);
|
|
58
64
|
|
|
59
65
|
expect(source).toBe(
|
|
60
66
|
[
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
`import * as page0 from ${JSON.stringify(toSpecifier(indexAbs))};`,
|
|
68
|
+
`import * as page1 from ${JSON.stringify(toSpecifier(adminAbs))};`,
|
|
63
69
|
"export const pages = {",
|
|
64
70
|
' "./_index.tsx": { loader: async () => page0, isAsyncDefault: false },',
|
|
65
71
|
' "./admin.tsx": { loader: async () => page1, isAsyncDefault: false },',
|
|
@@ -16,8 +16,8 @@ export class PagesEntrySourceGenerator {
|
|
|
16
16
|
|
|
17
17
|
generate(): string {
|
|
18
18
|
const lines = this.#pageEntries.map(({ key, moduleAbsPath }) => {
|
|
19
|
-
const
|
|
20
|
-
return ` ${JSON.stringify(key)}: () => import(${JSON.stringify(
|
|
19
|
+
const specifier = PagesEntrySourceGenerator.#toImportSpecifier(moduleAbsPath);
|
|
20
|
+
return ` ${JSON.stringify(key)}: () => import(${JSON.stringify(specifier)}),`;
|
|
21
21
|
});
|
|
22
22
|
return `export const pages = {\n${lines.join("\n")}\n};\n`;
|
|
23
23
|
}
|
|
@@ -28,8 +28,8 @@ export class PagesEntrySourceGenerator {
|
|
|
28
28
|
|
|
29
29
|
generateStatic(): string {
|
|
30
30
|
const imports = this.#pageEntries.map(({ moduleAbsPath }, index) => {
|
|
31
|
-
const
|
|
32
|
-
return `import * as page${index} from ${JSON.stringify(
|
|
31
|
+
const specifier = PagesEntrySourceGenerator.#toImportSpecifier(moduleAbsPath);
|
|
32
|
+
return `import * as page${index} from ${JSON.stringify(specifier)};`;
|
|
33
33
|
});
|
|
34
34
|
const entries = this.#pageEntries.map(({ key, moduleAbsPath }, index) => {
|
|
35
35
|
const isAsyncDefault = PagesEntrySourceGenerator.#hasAsyncDefaultExport(moduleAbsPath);
|
|
@@ -37,6 +37,9 @@ export class PagesEntrySourceGenerator {
|
|
|
37
37
|
});
|
|
38
38
|
return `${imports.join("\n")}\nexport const pages = {\n${entries.join("\n")}\n};\n`;
|
|
39
39
|
}
|
|
40
|
+
static #toImportSpecifier(moduleAbsPath: string): string {
|
|
41
|
+
return path.resolve(moduleAbsPath).split(path.sep).join("/");
|
|
42
|
+
}
|
|
40
43
|
|
|
41
44
|
static #hasAsyncDefaultExport(moduleAbsPath: string): boolean {
|
|
42
45
|
try {
|
|
@@ -99,11 +99,15 @@ export class SsrBaseArtifactBuilder {
|
|
|
99
99
|
}
|
|
100
100
|
> {
|
|
101
101
|
const akanServerPath = await this.#resolveAkanServerPath();
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
// Normalize entry paths with path.resolve so they match the resolved map keys the bundler
|
|
103
|
+
// stores (see ClientEntriesBundler#createOpaqueEntryAliases). Raw string concatenation keeps
|
|
104
|
+
// forward slashes, which on Windows fail to match the `\`-separated resolved keys and silently
|
|
105
|
+
// yield empty import-map URLs, breaking hydration.
|
|
106
|
+
const rscClientEntry = path.resolve(akanServerPath, "rscClient.tsx");
|
|
107
|
+
const rscSegmentOutletEntry = path.resolve(akanServerPath, "rscSegmentOutlet.tsx");
|
|
104
108
|
const vendorEntries = VENDOR_SPECIFIERS.map((specifier) => ({
|
|
105
109
|
specifier,
|
|
106
|
-
absPath:
|
|
110
|
+
absPath: path.resolve(akanServerPath, "vendor", `${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`),
|
|
107
111
|
}));
|
|
108
112
|
const entries = [rscClientEntry, rscSegmentOutletEntry, ...vendorEntries.map((v) => v.absPath)];
|
|
109
113
|
const clientBundle = await new ClientEntriesBundler({ app: this.#app, entries, command: this.#command }).bundle();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "2.3.10-rc.
|
|
3
|
+
"version": "2.3.10-rc.2",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@langchain/openai": "^1.4.6",
|
|
33
33
|
"@tailwindcss/node": "^4.3.0",
|
|
34
34
|
"@trapezedev/project": "^7.1.4",
|
|
35
|
-
"akanjs": "2.3.10-rc.
|
|
35
|
+
"akanjs": "2.3.10-rc.2",
|
|
36
36
|
"chalk": "^5.6.2",
|
|
37
37
|
"commander": "^14.0.3",
|
|
38
38
|
"daisyui": "5.5.23",
|