@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/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}
|
|
@@ -2639,6 +2672,7 @@ export async function initGarfishMaster(): Promise<void> {
|
|
|
2639
2672
|
// src/plugin/builtin/tailwind.ts
|
|
2640
2673
|
import { existsSync as existsSync7, writeFileSync as writeFileSync3 } from "fs";
|
|
2641
2674
|
import { join as join7 } from "path";
|
|
2675
|
+
import { rspack as rspack3 } from "@rspack/core";
|
|
2642
2676
|
var tailwindPlugin = createPlugin((options = {}) => ({
|
|
2643
2677
|
name: "@4399ywkf/plugin-tailwind",
|
|
2644
2678
|
version: "1.0.0",
|
|
@@ -2662,7 +2696,7 @@ var tailwindPlugin = createPlugin((options = {}) => ({
|
|
|
2662
2696
|
const tailwindRule = {
|
|
2663
2697
|
test: /tailwind\.css$/,
|
|
2664
2698
|
use: [
|
|
2665
|
-
isProd ?
|
|
2699
|
+
isProd ? rspack3.CssExtractRspackPlugin.loader : "style-loader",
|
|
2666
2700
|
"css-loader",
|
|
2667
2701
|
{
|
|
2668
2702
|
loader: "postcss-loader",
|
|
@@ -3545,7 +3579,7 @@ export type { StateCreator, StoreApi } from "zustand";
|
|
|
3545
3579
|
}
|
|
3546
3580
|
|
|
3547
3581
|
// src/cli/dev.ts
|
|
3548
|
-
import { rspack as
|
|
3582
|
+
import { rspack as rspack4 } from "@rspack/core";
|
|
3549
3583
|
import { RspackDevServer } from "@rspack/dev-server";
|
|
3550
3584
|
import chalk2 from "chalk";
|
|
3551
3585
|
|
|
@@ -3856,7 +3890,7 @@ async function dev(options = {}) {
|
|
|
3856
3890
|
printer.updateProgress(0, "preparing");
|
|
3857
3891
|
rspackConfig.plugins = rspackConfig.plugins || [];
|
|
3858
3892
|
rspackConfig.plugins.push(
|
|
3859
|
-
new
|
|
3893
|
+
new rspack4.ProgressPlugin(createProgressHandler(printer))
|
|
3860
3894
|
);
|
|
3861
3895
|
rspackConfig.stats = "none";
|
|
3862
3896
|
rspackConfig.infrastructureLogging = { level: "none" };
|
|
@@ -3870,7 +3904,7 @@ async function dev(options = {}) {
|
|
|
3870
3904
|
progress: false
|
|
3871
3905
|
};
|
|
3872
3906
|
}
|
|
3873
|
-
const compiler =
|
|
3907
|
+
const compiler = rspack4(rspackConfig);
|
|
3874
3908
|
compiler.hooks.done.tap("ywkf-dev-printer", (stats) => {
|
|
3875
3909
|
const hasErrors = stats.hasErrors();
|
|
3876
3910
|
if (hasErrors) {
|
|
@@ -3920,7 +3954,7 @@ async function dev(options = {}) {
|
|
|
3920
3954
|
}
|
|
3921
3955
|
|
|
3922
3956
|
// src/cli/build.ts
|
|
3923
|
-
import { rspack as
|
|
3957
|
+
import { rspack as rspack5 } from "@rspack/core";
|
|
3924
3958
|
import chalk3 from "chalk";
|
|
3925
3959
|
function formatSize(bytes) {
|
|
3926
3960
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -3981,11 +4015,11 @@ async function build(options = {}) {
|
|
|
3981
4015
|
printer.updateProgress(0, "preparing");
|
|
3982
4016
|
rspackConfig.plugins = rspackConfig.plugins || [];
|
|
3983
4017
|
rspackConfig.plugins.push(
|
|
3984
|
-
new
|
|
4018
|
+
new rspack5.ProgressPlugin(createProgressHandler(printer))
|
|
3985
4019
|
);
|
|
3986
4020
|
rspackConfig.stats = "none";
|
|
3987
4021
|
rspackConfig.infrastructureLogging = { level: "none" };
|
|
3988
|
-
const compiler =
|
|
4022
|
+
const compiler = rspack5(rspackConfig);
|
|
3989
4023
|
const stats = await new Promise((resolve4, reject) => {
|
|
3990
4024
|
compiler.run((err, stats2) => {
|
|
3991
4025
|
if (err) {
|