@4399ywkf/core 5.0.10 → 5.0.12
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/dist/cli/index.js +44 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +56 -22
- package/dist/index.js.map +1 -1
- package/dist/router/index.js +44 -11
- package/dist/router/index.js.map +1 -1
- package/dist/rspack/index.js +44 -11
- package/dist/rspack/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -168,8 +168,21 @@ import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as wr
|
|
|
168
168
|
import { join as join3 } from "path";
|
|
169
169
|
|
|
170
170
|
// src/router/generator.ts
|
|
171
|
-
import {
|
|
171
|
+
import {
|
|
172
|
+
existsSync as existsSync2,
|
|
173
|
+
readdirSync,
|
|
174
|
+
statSync,
|
|
175
|
+
mkdirSync,
|
|
176
|
+
writeFileSync
|
|
177
|
+
} from "fs";
|
|
172
178
|
import { join, relative } from "path";
|
|
179
|
+
function winPath(path) {
|
|
180
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
|
181
|
+
if (isExtendedLengthPath) {
|
|
182
|
+
return path;
|
|
183
|
+
}
|
|
184
|
+
return path.replace(/\\/g, "/");
|
|
185
|
+
}
|
|
173
186
|
var EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
174
187
|
"components",
|
|
175
188
|
"hooks",
|
|
@@ -226,14 +239,17 @@ var ConventionalRouteGenerator = class {
|
|
|
226
239
|
);
|
|
227
240
|
if (pathlessLayout) {
|
|
228
241
|
const pathlessChildren = this.scanDirectory(subDirPath, routePath);
|
|
242
|
+
const pathlessLayoutRel = winPath(
|
|
243
|
+
relative(this.options.pagesDir, join(subDirPath, pathlessLayout))
|
|
244
|
+
);
|
|
229
245
|
childRoutes.push({
|
|
230
246
|
path: routePath,
|
|
231
247
|
name: this.generateRouteName(subDir.slice(2)),
|
|
232
|
-
layoutFile:
|
|
248
|
+
layoutFile: pathlessLayoutRel,
|
|
233
249
|
isLayout: true,
|
|
234
250
|
pathless: true,
|
|
235
251
|
children: pathlessChildren.filter(
|
|
236
|
-
(r) => r.layoutFile !==
|
|
252
|
+
(r) => r.layoutFile !== pathlessLayoutRel
|
|
237
253
|
)
|
|
238
254
|
});
|
|
239
255
|
} else {
|
|
@@ -245,7 +261,7 @@ var ConventionalRouteGenerator = class {
|
|
|
245
261
|
childRoutes.push(...this.scanDirectory(subDirPath, subRoutePath));
|
|
246
262
|
}
|
|
247
263
|
const routeName = this.generateRouteName(routePath);
|
|
248
|
-
const relPath = (file) => relative(this.options.pagesDir, join(dir, file));
|
|
264
|
+
const relPath = (file) => winPath(relative(this.options.pagesDir, join(dir, file)));
|
|
249
265
|
if (layoutFile) {
|
|
250
266
|
const layoutChildren = [];
|
|
251
267
|
if (pageFile) {
|
|
@@ -391,26 +407,39 @@ export default routes;
|
|
|
391
407
|
const toImportPath = (f) => f.replace(/\.(tsx?|jsx?)$/, "");
|
|
392
408
|
if (route.isLayout && route.layoutFile) {
|
|
393
409
|
lazyImports.push(
|
|
394
|
-
`const ${name}Layout = lazy(() => import("@/pages/${toImportPath(
|
|
410
|
+
`const ${name}Layout = lazy(() => import("@/pages/${toImportPath(
|
|
411
|
+
route.layoutFile
|
|
412
|
+
)}"));`
|
|
395
413
|
);
|
|
396
414
|
}
|
|
397
415
|
if (route.file) {
|
|
398
416
|
lazyImports.push(
|
|
399
|
-
`const ${name}Page = lazy(() => import("@/pages/${toImportPath(
|
|
417
|
+
`const ${name}Page = lazy(() => import("@/pages/${toImportPath(
|
|
418
|
+
route.file
|
|
419
|
+
)}"));`
|
|
400
420
|
);
|
|
401
421
|
}
|
|
402
422
|
if (route.errorFile) {
|
|
403
423
|
errorImports.push(
|
|
404
|
-
`const ${name}Error = lazy(() => import("@/pages/${toImportPath(
|
|
424
|
+
`const ${name}Error = lazy(() => import("@/pages/${toImportPath(
|
|
425
|
+
route.errorFile
|
|
426
|
+
)}"));`
|
|
405
427
|
);
|
|
406
428
|
}
|
|
407
429
|
if (route.loadingFile) {
|
|
408
430
|
loadingImports.push(
|
|
409
|
-
`const ${name}Loading = lazy(() => import("@/pages/${toImportPath(
|
|
431
|
+
`const ${name}Loading = lazy(() => import("@/pages/${toImportPath(
|
|
432
|
+
route.loadingFile
|
|
433
|
+
)}"));`
|
|
410
434
|
);
|
|
411
435
|
}
|
|
412
436
|
if (route.children) {
|
|
413
|
-
this.collectImports(
|
|
437
|
+
this.collectImports(
|
|
438
|
+
route.children,
|
|
439
|
+
lazyImports,
|
|
440
|
+
errorImports,
|
|
441
|
+
loadingImports
|
|
442
|
+
);
|
|
414
443
|
}
|
|
415
444
|
}
|
|
416
445
|
}
|
|
@@ -436,7 +465,9 @@ export default routes;
|
|
|
436
465
|
}
|
|
437
466
|
if (route.isLayout && route.layoutFile) {
|
|
438
467
|
const loadingProp = route.loadingFile ? ` Loading={${name}Loading}` : "";
|
|
439
|
-
parts.push(
|
|
468
|
+
parts.push(
|
|
469
|
+
`element: <LazyRoute Component={${name}Layout}${loadingProp} />`
|
|
470
|
+
);
|
|
440
471
|
} else if (route.file) {
|
|
441
472
|
parts.push(`element: <LazyRoute Component={${name}Page} />`);
|
|
442
473
|
}
|
|
@@ -445,7 +476,9 @@ export default routes;
|
|
|
445
476
|
}
|
|
446
477
|
if (route.children && route.children.length > 0) {
|
|
447
478
|
const childParent = route.pathless ? parentPath : route.path;
|
|
448
|
-
parts.push(
|
|
479
|
+
parts.push(
|
|
480
|
+
`children: ${this.emitRouteArray(route.children, childParent)}`
|
|
481
|
+
);
|
|
449
482
|
}
|
|
450
483
|
return `{
|
|
451
484
|
${parts.join(",\n ")}
|