@akanjs/devkit 2.3.10-rc.0 → 2.3.10-rc.1

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
- const baseParts = this.cwdPath.split("/").filter(Boolean);
441
- const targetParts = filePath.split("/").filter(Boolean);
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
- const result =
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);
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
2
2
  import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { fileURLToPath } from "node:url";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import type { RoutesManifest } from "akanjs/server";
7
7
  import { CsrArtifactBuilder } from "./csrArtifactBuilder";
8
8
  import { CssCompiler, isIgnoredNodeModuleSource } from "./cssCompiler";
@@ -33,17 +33,19 @@ afterEach(async () => {
33
33
  });
34
34
 
35
35
  describe("PagesEntrySourceGenerator", () => {
36
- test("generates dynamic import source using absolute module paths", () => {
36
+ test("generates dynamic import source using file:// module URLs", () => {
37
+ const indexAbs = path.resolve("/repo/apps/demo/page/_index.tsx");
38
+ const adminAbs = path.resolve("/repo/apps/demo/page/admin.tsx");
37
39
  const source = PagesEntrySourceGenerator.generate([
38
- { key: "./_index.tsx", moduleAbsPath: "/repo/apps/demo/page/_index.tsx" },
39
- { key: "./admin.tsx", moduleAbsPath: "/repo/apps/demo/page/admin.tsx" },
40
+ { key: "./_index.tsx", moduleAbsPath: indexAbs },
41
+ { key: "./admin.tsx", moduleAbsPath: adminAbs },
40
42
  ]);
41
43
 
42
44
  expect(source).toBe(
43
45
  [
44
46
  "export const pages = {",
45
- ' "./_index.tsx": () => import("/repo/apps/demo/page/_index.tsx"),',
46
- ' "./admin.tsx": () => import("/repo/apps/demo/page/admin.tsx"),',
47
+ ` "./_index.tsx": () => import(${JSON.stringify(pathToFileURL(indexAbs).href)}),`,
48
+ ` "./admin.tsx": () => import(${JSON.stringify(pathToFileURL(adminAbs).href)}),`,
47
49
  "};",
48
50
  "",
49
51
  ].join("\n"),
@@ -51,15 +53,17 @@ describe("PagesEntrySourceGenerator", () => {
51
53
  });
52
54
 
53
55
  test("generates static import source for single-file CSR bundles", () => {
56
+ const indexAbs = path.resolve("/repo/apps/demo/page/_index.tsx");
57
+ const adminAbs = path.resolve("/repo/apps/demo/page/admin.tsx");
54
58
  const source = PagesEntrySourceGenerator.generateStatic([
55
- { key: "./_index.tsx", moduleAbsPath: "/repo/apps/demo/page/_index.tsx" },
56
- { key: "./admin.tsx", moduleAbsPath: "/repo/apps/demo/page/admin.tsx" },
59
+ { key: "./_index.tsx", moduleAbsPath: indexAbs },
60
+ { key: "./admin.tsx", moduleAbsPath: adminAbs },
57
61
  ]);
58
62
 
59
63
  expect(source).toBe(
60
64
  [
61
- 'import * as page0 from "/repo/apps/demo/page/_index.tsx";',
62
- 'import * as page1 from "/repo/apps/demo/page/admin.tsx";',
65
+ `import * as page0 from ${JSON.stringify(pathToFileURL(indexAbs).href)};`,
66
+ `import * as page1 from ${JSON.stringify(pathToFileURL(adminAbs).href)};`,
63
67
  "export const pages = {",
64
68
  ' "./_index.tsx": { loader: async () => page0, isAsyncDefault: false },',
65
69
  ' "./admin.tsx": { loader: async () => page1, isAsyncDefault: false },',
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
3
4
  import ts from "typescript";
4
5
  import type { PageEntry } from "../artifact/implicitRootLayout";
5
6
 
@@ -16,8 +17,8 @@ export class PagesEntrySourceGenerator {
16
17
 
17
18
  generate(): string {
18
19
  const lines = this.#pageEntries.map(({ key, moduleAbsPath }) => {
19
- const absPath = path.resolve(moduleAbsPath);
20
- return ` ${JSON.stringify(key)}: () => import(${JSON.stringify(absPath)}),`;
20
+ const specifier = pathToFileURL(path.resolve(moduleAbsPath)).href;
21
+ return ` ${JSON.stringify(key)}: () => import(${JSON.stringify(specifier)}),`;
21
22
  });
22
23
  return `export const pages = {\n${lines.join("\n")}\n};\n`;
23
24
  }
@@ -28,8 +29,10 @@ export class PagesEntrySourceGenerator {
28
29
 
29
30
  generateStatic(): string {
30
31
  const imports = this.#pageEntries.map(({ moduleAbsPath }, index) => {
31
- const absPath = path.resolve(moduleAbsPath);
32
- return `import * as page${index} from ${JSON.stringify(absPath)};`;
32
+ // Emit a file:// URL so the specifier is separator-agnostic; a raw Windows path
33
+ // (backslashes, or mixed with forward slashes) is a fragile ESM import specifier.
34
+ const specifier = pathToFileURL(path.resolve(moduleAbsPath)).href;
35
+ return `import * as page${index} from ${JSON.stringify(specifier)};`;
33
36
  });
34
37
  const entries = this.#pageEntries.map(({ key, moduleAbsPath }, index) => {
35
38
  const isAsyncDefault = PagesEntrySourceGenerator.#hasAsyncDefaultExport(moduleAbsPath);
@@ -99,11 +99,15 @@ export class SsrBaseArtifactBuilder {
99
99
  }
100
100
  > {
101
101
  const akanServerPath = await this.#resolveAkanServerPath();
102
- const rscClientEntry = `${akanServerPath}/rscClient.tsx`;
103
- const rscSegmentOutletEntry = `${akanServerPath}/rscSegmentOutlet.tsx`;
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: `${akanServerPath}/vendor/${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`,
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.0",
3
+ "version": "2.3.10-rc.1",
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.0",
35
+ "akanjs": "2.3.10-rc.1",
36
36
  "chalk": "^5.6.2",
37
37
  "commander": "^14.0.3",
38
38
  "daisyui": "5.5.23",