@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.
- package/package.json +1 -1
- package/src/bundler/dev.ts +22 -16
package/package.json
CHANGED
package/src/bundler/dev.ts
CHANGED
|
@@ -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
|
-
//
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
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
|
|