@mandujs/core 0.18.0 → 0.18.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/package.json +1 -1
- package/src/router/fs-scanner.ts +21 -6
package/package.json
CHANGED
package/src/router/fs-scanner.ts
CHANGED
|
@@ -81,7 +81,7 @@ export class FSScanner {
|
|
|
81
81
|
await this.scanWithGlob(rootDir, routesDir, files, errors);
|
|
82
82
|
|
|
83
83
|
// 라우트 설정 생성
|
|
84
|
-
const { routes, routeErrors } = this.createRouteConfigs(files, rootDir);
|
|
84
|
+
const { routes, routeErrors } = await this.createRouteConfigs(files, rootDir);
|
|
85
85
|
errors.push(...routeErrors);
|
|
86
86
|
|
|
87
87
|
// 통계 계산
|
|
@@ -187,10 +187,10 @@ export class FSScanner {
|
|
|
187
187
|
/**
|
|
188
188
|
* 스캔된 파일에서 라우트 설정 생성
|
|
189
189
|
*/
|
|
190
|
-
private createRouteConfigs(
|
|
190
|
+
private async createRouteConfigs(
|
|
191
191
|
files: ScannedFile[],
|
|
192
192
|
rootDir: string
|
|
193
|
-
): { routes: FSRouteConfig[]; routeErrors: ScanError[] } {
|
|
193
|
+
): Promise<{ routes: FSRouteConfig[]; routeErrors: ScanError[] }> {
|
|
194
194
|
const routes: FSRouteConfig[] = [];
|
|
195
195
|
const routeErrors: ScanError[] = [];
|
|
196
196
|
|
|
@@ -273,9 +273,24 @@ export class FSScanner {
|
|
|
273
273
|
// Island 파일 찾기 (같은 디렉토리)
|
|
274
274
|
const dirPath = this.getDirPath(file.relativePath);
|
|
275
275
|
const islands = islandMap.get(dirPath);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
|
|
277
|
+
// clientModule 결정: island 파일 또는 "use client"가 있는 page 자체
|
|
278
|
+
let clientModule: string | undefined;
|
|
279
|
+
if (islands?.[0]) {
|
|
280
|
+
// 우선순위: 명시적 island 파일
|
|
281
|
+
clientModule = join(this.config.routesDir, islands[0].relativePath);
|
|
282
|
+
} else if (file.type === "page") {
|
|
283
|
+
// page 파일 자체에서 "use client" 확인
|
|
284
|
+
try {
|
|
285
|
+
const fileContent = await Bun.file(file.absolutePath).text();
|
|
286
|
+
const hasUseClient = /^\s*["']use client["']/m.test(fileContent);
|
|
287
|
+
if (hasUseClient) {
|
|
288
|
+
clientModule = modulePath;
|
|
289
|
+
}
|
|
290
|
+
} catch {
|
|
291
|
+
// 파일 읽기 실패 시 무시
|
|
292
|
+
}
|
|
293
|
+
}
|
|
279
294
|
|
|
280
295
|
// 로딩/에러 모듈 찾기
|
|
281
296
|
const loadingModule = this.findClosestSpecialFile(file.segments, loadingMap);
|