@umijs/preset-umi 4.0.83 → 4.0.84
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.
|
@@ -94,10 +94,43 @@ async function getRoutes(opts) {
|
|
|
94
94
|
return path;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
const absLayoutPath = ((_c = opts.api.config) == null ? void 0 : _c.conventionLayout) === false ? false : (0, import_utils.tryPaths)([
|
|
98
|
+
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.tsx"),
|
|
99
|
+
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.vue"),
|
|
100
|
+
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.jsx"),
|
|
101
|
+
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.js")
|
|
102
|
+
]);
|
|
103
|
+
const layouts = await opts.api.applyPlugins({
|
|
104
|
+
key: "addLayouts",
|
|
105
|
+
initialValue: [
|
|
106
|
+
absLayoutPath && {
|
|
107
|
+
id: "@@/global-layout",
|
|
108
|
+
file: (0, import_utils.winPath)(absLayoutPath),
|
|
109
|
+
test(route) {
|
|
110
|
+
return route.layout !== false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
].filter(Boolean)
|
|
114
|
+
});
|
|
115
|
+
for (const layout of layouts) {
|
|
116
|
+
(0, import_core.addParentRoute)({
|
|
117
|
+
addToAll: true,
|
|
118
|
+
target: {
|
|
119
|
+
id: layout.id,
|
|
120
|
+
path: "/",
|
|
121
|
+
file: layout.file,
|
|
122
|
+
parentId: void 0,
|
|
123
|
+
absPath: "/",
|
|
124
|
+
isLayout: true
|
|
125
|
+
},
|
|
126
|
+
routes,
|
|
127
|
+
test: layout.test
|
|
128
|
+
});
|
|
129
|
+
}
|
|
97
130
|
for (const id of Object.keys(routes)) {
|
|
98
131
|
if (routes[id].file) {
|
|
99
132
|
let file = routes[id].file;
|
|
100
|
-
const basedir = ((
|
|
133
|
+
const basedir = ((_d = opts.api.config.conventionRoutes) == null ? void 0 : _d.base) || opts.api.paths.absPagesPath;
|
|
101
134
|
if (!(0, import_path.isAbsolute)(file)) {
|
|
102
135
|
if (file.startsWith("@/")) {
|
|
103
136
|
file = file.replace("@/", "../");
|
|
@@ -108,9 +141,11 @@ async function getRoutes(opts) {
|
|
|
108
141
|
});
|
|
109
142
|
}
|
|
110
143
|
const isJSFile = /.[jt]sx?$/.test(file);
|
|
111
|
-
routes[id].
|
|
144
|
+
if (!routes[id].isLayout) {
|
|
145
|
+
routes[id].__content = (0, import_fs.readFileSync)(file, "utf-8");
|
|
146
|
+
routes[id].__isJSFile = isJSFile;
|
|
147
|
+
}
|
|
112
148
|
routes[id].__absFile = (0, import_utils.winPath)(file);
|
|
113
|
-
routes[id].__isJSFile = isJSFile;
|
|
114
149
|
const enableSSR = opts.api.config.ssr;
|
|
115
150
|
const enableClientLoader = opts.api.config.clientLoader;
|
|
116
151
|
const enableRouteProps = !opts.api.userConfig.routes;
|
|
@@ -131,39 +166,6 @@ async function getRoutes(opts) {
|
|
|
131
166
|
}
|
|
132
167
|
}
|
|
133
168
|
}
|
|
134
|
-
const absLayoutPath = ((_d = opts.api.config) == null ? void 0 : _d.conventionLayout) === false ? false : (0, import_utils.tryPaths)([
|
|
135
|
-
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.tsx"),
|
|
136
|
-
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.vue"),
|
|
137
|
-
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.jsx"),
|
|
138
|
-
(0, import_path.join)(opts.api.paths.absSrcPath, "layouts/index.js")
|
|
139
|
-
]);
|
|
140
|
-
const layouts = await opts.api.applyPlugins({
|
|
141
|
-
key: "addLayouts",
|
|
142
|
-
initialValue: [
|
|
143
|
-
absLayoutPath && {
|
|
144
|
-
id: "@@/global-layout",
|
|
145
|
-
file: (0, import_utils.winPath)(absLayoutPath),
|
|
146
|
-
test(route) {
|
|
147
|
-
return route.layout !== false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
].filter(Boolean)
|
|
151
|
-
});
|
|
152
|
-
for (const layout of layouts) {
|
|
153
|
-
(0, import_core.addParentRoute)({
|
|
154
|
-
addToAll: true,
|
|
155
|
-
target: {
|
|
156
|
-
id: layout.id,
|
|
157
|
-
path: "/",
|
|
158
|
-
file: layout.file,
|
|
159
|
-
parentId: void 0,
|
|
160
|
-
absPath: "/",
|
|
161
|
-
isLayout: true
|
|
162
|
-
},
|
|
163
|
-
routes,
|
|
164
|
-
test: layout.test
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
169
|
for (const id of Object.keys(routes)) {
|
|
168
170
|
await opts.api.applyPlugins({
|
|
169
171
|
key: "onPatchRoute",
|
|
@@ -407,6 +407,22 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
407
407
|
key: "addRuntimePlugin",
|
|
408
408
|
initialValue: [(_c = api.appData.appJS) == null ? void 0 : _c.path].filter(Boolean)
|
|
409
409
|
});
|
|
410
|
+
function checkDuplicatePluginKeys(arr) {
|
|
411
|
+
const duplicates = [];
|
|
412
|
+
arr.reduce((prev, curr) => {
|
|
413
|
+
if (prev[curr]) {
|
|
414
|
+
duplicates.push(curr);
|
|
415
|
+
} else {
|
|
416
|
+
prev[curr] = true;
|
|
417
|
+
}
|
|
418
|
+
return prev;
|
|
419
|
+
}, {});
|
|
420
|
+
if (duplicates.length) {
|
|
421
|
+
throw new Error(
|
|
422
|
+
`The plugin key cannot be duplicated. (${duplicates.join(", ")})`
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
410
426
|
const validKeys = await api.applyPlugins({
|
|
411
427
|
key: "addRuntimePluginKey",
|
|
412
428
|
initialValue: [
|
|
@@ -424,6 +440,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
424
440
|
"onRouteChange"
|
|
425
441
|
]
|
|
426
442
|
});
|
|
443
|
+
checkDuplicatePluginKeys(validKeys);
|
|
427
444
|
const appPluginRegExp = /(\/|\\)app.(ts|tsx|jsx|js)$/;
|
|
428
445
|
api.writeTmpFile({
|
|
429
446
|
noPluginDir: true,
|
|
@@ -654,5 +671,3 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
654
671
|
stage: 1e4
|
|
655
672
|
});
|
|
656
673
|
};
|
|
657
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
658
|
-
0 && (module.exports = {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.84",
|
|
4
4
|
"description": "@umijs/preset-umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"react-router": "6.3.0",
|
|
38
38
|
"react-router-dom": "6.3.0",
|
|
39
39
|
"regenerator-runtime": "0.13.11",
|
|
40
|
-
"@umijs/ast": "4.0.
|
|
41
|
-
"@umijs/bundler-
|
|
42
|
-
"@umijs/
|
|
43
|
-
"@umijs/
|
|
44
|
-
"@umijs/bundler-
|
|
45
|
-
"@umijs/bundler-
|
|
46
|
-
"@umijs/
|
|
40
|
+
"@umijs/ast": "4.0.84",
|
|
41
|
+
"@umijs/bundler-utils": "4.0.84",
|
|
42
|
+
"@umijs/babel-preset-umi": "4.0.84",
|
|
43
|
+
"@umijs/bundler-esbuild": "4.0.84",
|
|
44
|
+
"@umijs/bundler-webpack": "4.0.84",
|
|
45
|
+
"@umijs/bundler-vite": "4.0.84",
|
|
46
|
+
"@umijs/core": "4.0.84",
|
|
47
|
+
"@umijs/mfsu": "4.0.84",
|
|
48
|
+
"@umijs/renderer-react": "4.0.84",
|
|
49
|
+
"@umijs/plugin-run": "4.0.84",
|
|
50
|
+
"@umijs/server": "4.0.84",
|
|
47
51
|
"@umijs/did-you-know": "1.0.3",
|
|
48
|
-
"@umijs/
|
|
49
|
-
"@umijs/
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/core": "4.0.83",
|
|
52
|
-
"@umijs/zod2ts": "4.0.83",
|
|
53
|
-
"@umijs/ui": "3.0.1",
|
|
54
|
-
"@umijs/utils": "4.0.83"
|
|
52
|
+
"@umijs/zod2ts": "4.0.84",
|
|
53
|
+
"@umijs/utils": "4.0.84",
|
|
54
|
+
"@umijs/ui": "3.0.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@manypkg/get-packages": "1.1.3",
|
package/templates/server.tpl
CHANGED
|
@@ -4,7 +4,7 @@ import { createHistory as createClientHistory } from './core/history';
|
|
|
4
4
|
import { getPlugins as getClientPlugins } from './core/plugin';
|
|
5
5
|
import { ServerInsertedHTMLContext } from './core/serverInsertedHTMLContext';
|
|
6
6
|
import { PluginManager } from '{{{ umiPluginPath }}}';
|
|
7
|
-
import createRequestHandler, { createMarkupGenerator } from '{{{ umiServerPath }}}';
|
|
7
|
+
import createRequestHandler, { createMarkupGenerator, createUmiHandler, createUmiServerLoader } from '{{{ umiServerPath }}}';
|
|
8
8
|
|
|
9
9
|
let helmetContext;
|
|
10
10
|
|
|
@@ -54,6 +54,8 @@ const createOpts = {
|
|
|
54
54
|
ServerInsertedHTMLContext,
|
|
55
55
|
};
|
|
56
56
|
const requestHandler = createRequestHandler(createOpts);
|
|
57
|
+
export const renderRoot = createUmiHandler(createOpts);
|
|
58
|
+
export const serverLoader = createUmiServerLoader(createOpts);
|
|
57
59
|
|
|
58
60
|
export const _markupGenerator = createMarkupGenerator(createOpts);
|
|
59
61
|
|