@4399ywkf/core 5.1.4 → 5.1.6
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 +27 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +586 -28
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -3
- package/dist/router/index.js +12 -9
- package/dist/router/index.js.map +1 -1
- package/dist/rspack/index.d.ts +2 -2
- package/dist/rspack/index.js +26 -11
- package/dist/rspack/index.js.map +1 -1
- package/dist/runtime/index.d.ts +86 -4
- package/dist/runtime/index.js +578 -19
- package/dist/runtime/index.js.map +1 -1
- package/dist/{schema-C91lhskq.d.ts → schema-Ba1qfYz_.d.ts} +6 -1
- package/dist/{types-BYqzyGAY.d.ts → types-ZJhd87ue.d.ts} +51 -1
- package/package.json +8 -6
package/dist/cli/index.js
CHANGED
|
@@ -2125,6 +2125,7 @@ var defaultConfig = {
|
|
|
2125
2125
|
appName: "app",
|
|
2126
2126
|
appCName: "\u5E94\u7528",
|
|
2127
2127
|
strictMode: true,
|
|
2128
|
+
reactCompiler: false,
|
|
2128
2129
|
dev: {
|
|
2129
2130
|
port: 3e3,
|
|
2130
2131
|
host: "127.0.0.1",
|
|
@@ -2742,12 +2743,13 @@ function LazyRoute({
|
|
|
2742
2743
|
|
|
2743
2744
|
import React, { lazy, Suspense } from "react";
|
|
2744
2745
|
import { createBrowserRouter, type RouteObject } from "react-router";
|
|
2746
|
+
import { RouteErrorBoundary } from "@4399ywkf/core/runtime";
|
|
2747
|
+
${errorImports.length > 0 ? `
|
|
2748
|
+
// \u540C\u6B65\u9519\u8BEF\u8FB9\u754C\u7EC4\u4EF6
|
|
2749
|
+
${errorImports.join("\n")}` : ""}
|
|
2745
2750
|
|
|
2746
2751
|
// \u61D2\u52A0\u8F7D\u9875\u9762\u7EC4\u4EF6
|
|
2747
2752
|
${lazyImports.join("\n")}
|
|
2748
|
-
${errorImports.length > 0 ? `
|
|
2749
|
-
// \u9519\u8BEF\u8FB9\u754C\u7EC4\u4EF6
|
|
2750
|
-
${errorImports.join("\n")}` : ""}
|
|
2751
2753
|
${loadingImports.length > 0 ? `
|
|
2752
2754
|
// \u52A0\u8F7D\u72B6\u6001\u7EC4\u4EF6
|
|
2753
2755
|
${loadingImports.join("\n")}` : ""}
|
|
@@ -2782,7 +2784,7 @@ export default routes;
|
|
|
2782
2784
|
}
|
|
2783
2785
|
if (route.errorFile) {
|
|
2784
2786
|
errorImports.push(
|
|
2785
|
-
`
|
|
2787
|
+
`import ${name}Error from "@/pages/${toImportPath(route.errorFile)}";`
|
|
2786
2788
|
);
|
|
2787
2789
|
}
|
|
2788
2790
|
if (route.loadingFile) {
|
|
@@ -2797,13 +2799,13 @@ export default routes;
|
|
|
2797
2799
|
}
|
|
2798
2800
|
}
|
|
2799
2801
|
}
|
|
2800
|
-
emitRouteArray(routes, parentPath) {
|
|
2801
|
-
const items = routes.map((r) => this.emitRouteObject(r, parentPath));
|
|
2802
|
+
emitRouteArray(routes, parentPath, depth = 0) {
|
|
2803
|
+
const items = routes.map((r) => this.emitRouteObject(r, parentPath, depth));
|
|
2802
2804
|
return `[
|
|
2803
2805
|
${items.join(",\n ")}
|
|
2804
2806
|
]`;
|
|
2805
2807
|
}
|
|
2806
|
-
emitRouteObject(route, parentPath) {
|
|
2808
|
+
emitRouteObject(route, parentPath, depth) {
|
|
2807
2809
|
const parts = [];
|
|
2808
2810
|
const name = route.name;
|
|
2809
2811
|
if (route.index) {
|
|
@@ -2824,11 +2826,13 @@ export default routes;
|
|
|
2824
2826
|
parts.push(`element: <LazyRoute Component={${name}Page} />`);
|
|
2825
2827
|
}
|
|
2826
2828
|
if (route.errorFile) {
|
|
2827
|
-
parts.push(`errorElement: <
|
|
2829
|
+
parts.push(`errorElement: <RouteErrorBoundary fallback={<${name}Error />} />`);
|
|
2830
|
+
} else if (depth === 0) {
|
|
2831
|
+
parts.push(`errorElement: <RouteErrorBoundary />`);
|
|
2828
2832
|
}
|
|
2829
2833
|
if (route.children && route.children.length > 0) {
|
|
2830
2834
|
const childParent = route.pathless ? parentPath : route.path;
|
|
2831
|
-
parts.push(`children: ${this.emitRouteArray(route.children, childParent)}`);
|
|
2835
|
+
parts.push(`children: ${this.emitRouteArray(route.children, childParent, depth + 1)}`);
|
|
2832
2836
|
}
|
|
2833
2837
|
return `{
|
|
2834
2838
|
${parts.join(",\n ")}
|
|
@@ -3437,10 +3441,20 @@ var YwkfGeneratorPlugin = class {
|
|
|
3437
3441
|
var require2 = createRequire(import.meta.url);
|
|
3438
3442
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
3439
3443
|
var coreNodeModules = join12(__dirname, "../../node_modules");
|
|
3444
|
+
function resolveYwkfBuildId(appName) {
|
|
3445
|
+
const releaseId = [
|
|
3446
|
+
process.env.YWKF_BUILD_ID,
|
|
3447
|
+
process.env.CI_COMMIT_SHA,
|
|
3448
|
+
process.env.GITHUB_SHA,
|
|
3449
|
+
process.env.GIT_COMMIT
|
|
3450
|
+
].find((value) => value?.trim())?.trim();
|
|
3451
|
+
return `${appName}:${releaseId || Date.now().toString(36)}`;
|
|
3452
|
+
}
|
|
3440
3453
|
function createBaseConfig(config, cwd, options = {}) {
|
|
3441
3454
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
3442
3455
|
const { resolveApp } = createPathResolver(cwd);
|
|
3443
|
-
const { appName, appCName, output, html, alias: userAlias, microFrontend, router } = config;
|
|
3456
|
+
const { appName, appCName, output, html, alias: userAlias, microFrontend, router, reactCompiler } = config;
|
|
3457
|
+
const buildId = resolveYwkfBuildId(appName);
|
|
3444
3458
|
const ywkfOutputDir = resolveApp(".ywkf");
|
|
3445
3459
|
const defaultAlias = {
|
|
3446
3460
|
"@": resolveApp("src"),
|
|
@@ -3526,7 +3540,8 @@ function createBaseConfig(config, cwd, options = {}) {
|
|
|
3526
3540
|
runtime: "automatic",
|
|
3527
3541
|
development: isDev,
|
|
3528
3542
|
refresh: isDev
|
|
3529
|
-
}
|
|
3543
|
+
},
|
|
3544
|
+
...reactCompiler ? { reactCompiler } : {}
|
|
3530
3545
|
},
|
|
3531
3546
|
target: "es2015"
|
|
3532
3547
|
},
|
|
@@ -3563,6 +3578,7 @@ function createBaseConfig(config, cwd, options = {}) {
|
|
|
3563
3578
|
Buffer: ["buffer", "Buffer"]
|
|
3564
3579
|
}),
|
|
3565
3580
|
new rspack2.DefinePlugin({
|
|
3581
|
+
"globalThis.__YWKF_BUILD_ID__": JSON.stringify(buildId),
|
|
3566
3582
|
"process.env": JSON.stringify(process.env)
|
|
3567
3583
|
}),
|
|
3568
3584
|
new rspack2.HtmlRspackPlugin({
|