@mandujs/core 0.18.6 → 0.18.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bundler/dev.ts +22 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/core",
3
- "version": "0.18.6",
3
+ "version": "0.18.7",
4
4
  "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -103,8 +103,18 @@ export async function startDevBundler(options: DevBundlerOptions): Promise<DevBu
103
103
  const normalizedPath = absPath.replace(/\\/g, "/");
104
104
  clientModuleToRoute.set(normalizedPath, route.id);
105
105
 
106
- // 감시할 디렉토리 추가
106
+ // Also register *.client.tsx/ts files in the same directory (#140)
107
+ // e.g. if clientModule is app/page.island.tsx, also map app/page.client.tsx → same routeId
107
108
  const dir = path.dirname(absPath);
109
+ const baseStem = path.basename(absPath).replace(/\.(island|client)\.(tsx?|jsx?)$/, "");
110
+ for (const ext of [".client.tsx", ".client.ts", ".client.jsx", ".client.js"]) {
111
+ const clientPath = path.join(dir, baseStem + ext).replace(/\\/g, "/");
112
+ if (clientPath !== normalizedPath) {
113
+ clientModuleToRoute.set(clientPath, route.id);
114
+ }
115
+ }
116
+
117
+ // 감시할 디렉토리 추가
108
118
  watchDirs.add(dir);
109
119
  }
110
120
  }
@@ -224,21 +234,17 @@ export async function startDevBundler(options: DevBundlerOptions): Promise<DevBu
224
234
  // clientModule 매핑에서 routeId 찾기
225
235
  let routeId = clientModuleToRoute.get(normalizedPath);
226
236
 
227
- // .client.ts 또는 .client.tsx 파일인 경우 파일명에서 routeId 추출
228
- if (!routeId) {
229
- let basename: string | null = null;
230
-
231
- if (changedFile.endsWith(".client.ts")) {
232
- basename = path.basename(changedFile, ".client.ts");
233
- } else if (changedFile.endsWith(".client.tsx")) {
234
- basename = path.basename(changedFile, ".client.tsx");
235
- }
236
-
237
- if (basename) {
238
- const route = manifest.routes.find((r) => r.id === basename);
239
- if (route) {
240
- routeId = route.id;
241
- }
237
+ // Fallback for *.client.tsx/ts: find route whose clientModule is in the same directory (#140)
238
+ // basename matching (e.g. "page" !== "index") is unreliable — use directory-based matching instead
239
+ if (!routeId && (changedFile.endsWith(".client.ts") || changedFile.endsWith(".client.tsx"))) {
240
+ const changedDir = path.dirname(path.resolve(rootDir, changedFile)).replace(/\\/g, "/");
241
+ const matchedRoute = manifest.routes.find((r) => {
242
+ if (!r.clientModule) return false;
243
+ const routeDir = path.dirname(path.resolve(rootDir, r.clientModule)).replace(/\\/g, "/");
244
+ return routeDir === changedDir;
245
+ });
246
+ if (matchedRoute) {
247
+ routeId = matchedRoute.id;
242
248
  }
243
249
  }
244
250