@4399ywkf/core 5.0.10 → 5.0.11
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 +48 -15
- 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/index.js
CHANGED
|
@@ -155,8 +155,21 @@ import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as wr
|
|
|
155
155
|
import { join as join3 } from "path";
|
|
156
156
|
|
|
157
157
|
// src/router/generator.ts
|
|
158
|
-
import {
|
|
158
|
+
import {
|
|
159
|
+
existsSync as existsSync2,
|
|
160
|
+
readdirSync,
|
|
161
|
+
statSync,
|
|
162
|
+
mkdirSync,
|
|
163
|
+
writeFileSync
|
|
164
|
+
} from "fs";
|
|
159
165
|
import { join, relative } from "path";
|
|
166
|
+
function winPath(path) {
|
|
167
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
|
168
|
+
if (isExtendedLengthPath) {
|
|
169
|
+
return path;
|
|
170
|
+
}
|
|
171
|
+
return path.replace(/\\/g, "/");
|
|
172
|
+
}
|
|
160
173
|
var EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
161
174
|
"components",
|
|
162
175
|
"hooks",
|
|
@@ -213,14 +226,17 @@ var ConventionalRouteGenerator = class {
|
|
|
213
226
|
);
|
|
214
227
|
if (pathlessLayout) {
|
|
215
228
|
const pathlessChildren = this.scanDirectory(subDirPath, routePath);
|
|
229
|
+
const pathlessLayoutRel = winPath(
|
|
230
|
+
relative(this.options.pagesDir, join(subDirPath, pathlessLayout))
|
|
231
|
+
);
|
|
216
232
|
childRoutes.push({
|
|
217
233
|
path: routePath,
|
|
218
234
|
name: this.generateRouteName(subDir.slice(2)),
|
|
219
|
-
layoutFile:
|
|
235
|
+
layoutFile: pathlessLayoutRel,
|
|
220
236
|
isLayout: true,
|
|
221
237
|
pathless: true,
|
|
222
238
|
children: pathlessChildren.filter(
|
|
223
|
-
(r) => r.layoutFile !==
|
|
239
|
+
(r) => r.layoutFile !== pathlessLayoutRel
|
|
224
240
|
)
|
|
225
241
|
});
|
|
226
242
|
} else {
|
|
@@ -232,7 +248,7 @@ var ConventionalRouteGenerator = class {
|
|
|
232
248
|
childRoutes.push(...this.scanDirectory(subDirPath, subRoutePath));
|
|
233
249
|
}
|
|
234
250
|
const routeName = this.generateRouteName(routePath);
|
|
235
|
-
const relPath = (file) => relative(this.options.pagesDir, join(dir, file));
|
|
251
|
+
const relPath = (file) => winPath(relative(this.options.pagesDir, join(dir, file)));
|
|
236
252
|
if (layoutFile) {
|
|
237
253
|
const layoutChildren = [];
|
|
238
254
|
if (pageFile) {
|
|
@@ -378,26 +394,39 @@ export default routes;
|
|
|
378
394
|
const toImportPath = (f) => f.replace(/\.(tsx?|jsx?)$/, "");
|
|
379
395
|
if (route.isLayout && route.layoutFile) {
|
|
380
396
|
lazyImports.push(
|
|
381
|
-
`const ${name}Layout = lazy(() => import("@/pages/${toImportPath(
|
|
397
|
+
`const ${name}Layout = lazy(() => import("@/pages/${toImportPath(
|
|
398
|
+
route.layoutFile
|
|
399
|
+
)}"));`
|
|
382
400
|
);
|
|
383
401
|
}
|
|
384
402
|
if (route.file) {
|
|
385
403
|
lazyImports.push(
|
|
386
|
-
`const ${name}Page = lazy(() => import("@/pages/${toImportPath(
|
|
404
|
+
`const ${name}Page = lazy(() => import("@/pages/${toImportPath(
|
|
405
|
+
route.file
|
|
406
|
+
)}"));`
|
|
387
407
|
);
|
|
388
408
|
}
|
|
389
409
|
if (route.errorFile) {
|
|
390
410
|
errorImports.push(
|
|
391
|
-
`const ${name}Error = lazy(() => import("@/pages/${toImportPath(
|
|
411
|
+
`const ${name}Error = lazy(() => import("@/pages/${toImportPath(
|
|
412
|
+
route.errorFile
|
|
413
|
+
)}"));`
|
|
392
414
|
);
|
|
393
415
|
}
|
|
394
416
|
if (route.loadingFile) {
|
|
395
417
|
loadingImports.push(
|
|
396
|
-
`const ${name}Loading = lazy(() => import("@/pages/${toImportPath(
|
|
418
|
+
`const ${name}Loading = lazy(() => import("@/pages/${toImportPath(
|
|
419
|
+
route.loadingFile
|
|
420
|
+
)}"));`
|
|
397
421
|
);
|
|
398
422
|
}
|
|
399
423
|
if (route.children) {
|
|
400
|
-
this.collectImports(
|
|
424
|
+
this.collectImports(
|
|
425
|
+
route.children,
|
|
426
|
+
lazyImports,
|
|
427
|
+
errorImports,
|
|
428
|
+
loadingImports
|
|
429
|
+
);
|
|
401
430
|
}
|
|
402
431
|
}
|
|
403
432
|
}
|
|
@@ -423,7 +452,9 @@ export default routes;
|
|
|
423
452
|
}
|
|
424
453
|
if (route.isLayout && route.layoutFile) {
|
|
425
454
|
const loadingProp = route.loadingFile ? ` Loading={${name}Loading}` : "";
|
|
426
|
-
parts.push(
|
|
455
|
+
parts.push(
|
|
456
|
+
`element: <LazyRoute Component={${name}Layout}${loadingProp} />`
|
|
457
|
+
);
|
|
427
458
|
} else if (route.file) {
|
|
428
459
|
parts.push(`element: <LazyRoute Component={${name}Page} />`);
|
|
429
460
|
}
|
|
@@ -432,7 +463,9 @@ export default routes;
|
|
|
432
463
|
}
|
|
433
464
|
if (route.children && route.children.length > 0) {
|
|
434
465
|
const childParent = route.pathless ? parentPath : route.path;
|
|
435
|
-
parts.push(
|
|
466
|
+
parts.push(
|
|
467
|
+
`children: ${this.emitRouteArray(route.children, childParent)}`
|
|
468
|
+
);
|
|
436
469
|
}
|
|
437
470
|
return `{
|
|
438
471
|
${parts.join(",\n ")}
|
|
@@ -2061,7 +2094,7 @@ function RootProvider({ config, children }) {
|
|
|
2061
2094
|
const {
|
|
2062
2095
|
appName = "app",
|
|
2063
2096
|
router,
|
|
2064
|
-
basename
|
|
2097
|
+
basename = "/",
|
|
2065
2098
|
strictMode = true,
|
|
2066
2099
|
antd = { enabled: true },
|
|
2067
2100
|
providers = [],
|
|
@@ -2069,7 +2102,7 @@ function RootProvider({ config, children }) {
|
|
|
2069
2102
|
} = config;
|
|
2070
2103
|
const appContextValue = {
|
|
2071
2104
|
appName,
|
|
2072
|
-
basename
|
|
2105
|
+
basename,
|
|
2073
2106
|
isDev: process.env.NODE_ENV === "development",
|
|
2074
2107
|
env: typeof process !== "undefined" ? process.env : {}
|
|
2075
2108
|
};
|
|
@@ -2610,7 +2643,7 @@ var garfishPlugin = createPlugin((options = {}) => ({
|
|
|
2610
2643
|
return hooks;
|
|
2611
2644
|
}
|
|
2612
2645
|
}));
|
|
2613
|
-
function generateMasterInitCode(apps,
|
|
2646
|
+
function generateMasterInitCode(apps, basename) {
|
|
2614
2647
|
const appConfigs = apps.map(
|
|
2615
2648
|
(app) => `{
|
|
2616
2649
|
name: "${app.name}",
|
|
@@ -2626,7 +2659,7 @@ function generateMasterInitCode(apps, basename2) {
|
|
|
2626
2659
|
*/
|
|
2627
2660
|
export async function initGarfishMaster(): Promise<void> {
|
|
2628
2661
|
await Garfish.run({
|
|
2629
|
-
basename: "${
|
|
2662
|
+
basename: "${basename || "/"}",
|
|
2630
2663
|
domGetter: "#subapp-container",
|
|
2631
2664
|
apps: [
|
|
2632
2665
|
${appConfigs}
|