@umijs/preset-umi 4.0.71 → 4.0.73
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/commands/dev/createRouteMiddleware.js +7 -1
- package/dist/commands/dev/dev.js +3 -0
- package/dist/features/check/babel722.d.ts +3 -0
- package/dist/features/check/babel722.js +85 -0
- package/dist/features/devTool/devTool.js +2 -0
- package/dist/features/ssr/ssr.js +23 -0
- package/dist/features/tmpFiles/tmpFiles.js +11 -0
- package/dist/index.js +1 -0
- package/package.json +15 -15
- package/templates/server.tpl +2 -0
|
@@ -29,11 +29,17 @@ function createRouteMiddleware(opts) {
|
|
|
29
29
|
return ({ compiler }) => {
|
|
30
30
|
let webpackStats = null;
|
|
31
31
|
let onStats = null;
|
|
32
|
-
compiler.hooks.done.tap("umiRouteMiddleware", (stats) => {
|
|
32
|
+
compiler == null ? void 0 : compiler.hooks.done.tap("umiRouteMiddleware", (stats) => {
|
|
33
33
|
webpackStats = stats;
|
|
34
34
|
onStats == null ? void 0 : onStats(stats);
|
|
35
35
|
});
|
|
36
36
|
async function getStats() {
|
|
37
|
+
if (!compiler && process.env.OKAM) {
|
|
38
|
+
return {
|
|
39
|
+
compilation: { assets: { "umi.js": "umi.js" } },
|
|
40
|
+
hasErrors: () => false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
37
43
|
if (webpackStats)
|
|
38
44
|
return Promise.resolve(webpackStats);
|
|
39
45
|
return new Promise((resolve) => {
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/features/check/babel722.ts
|
|
20
|
+
var babel722_exports = {};
|
|
21
|
+
__export(babel722_exports, {
|
|
22
|
+
default: () => babel722_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(babel722_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var DEPRECATED_DEPS = [
|
|
27
|
+
"unicode-sets-regex",
|
|
28
|
+
"class-static-block",
|
|
29
|
+
"private-property-in-object",
|
|
30
|
+
"class-properties",
|
|
31
|
+
"private-methods",
|
|
32
|
+
"numeric-separator",
|
|
33
|
+
"logical-assignment-operators",
|
|
34
|
+
"nullish-coalescing-operator",
|
|
35
|
+
"optional-chaining",
|
|
36
|
+
"export-namespace-from",
|
|
37
|
+
"json-strings",
|
|
38
|
+
"optional-catch-binding",
|
|
39
|
+
"async-generator-functions",
|
|
40
|
+
"object-rest-spread",
|
|
41
|
+
"unicode-property-regex"
|
|
42
|
+
];
|
|
43
|
+
var BABEL_PROPOSAL_PREFIX = "@babel/plugin-proposal-";
|
|
44
|
+
var BABEL_TRANSFORM_PREFIX = "@babel/plugin-transform-";
|
|
45
|
+
var babel722_default = (api) => {
|
|
46
|
+
api.onCheck(() => {
|
|
47
|
+
const pkg = api.pkg;
|
|
48
|
+
const breakingDeps = DEPRECATED_DEPS.map(
|
|
49
|
+
(i) => `${BABEL_PROPOSAL_PREFIX}${i}`
|
|
50
|
+
);
|
|
51
|
+
const deps = Object.keys({
|
|
52
|
+
...(pkg == null ? void 0 : pkg.dependencies) || {},
|
|
53
|
+
...(pkg == null ? void 0 : pkg.devDependencies) || {}
|
|
54
|
+
});
|
|
55
|
+
const willBreakingDeps = deps.filter((i) => breakingDeps.includes(i));
|
|
56
|
+
if (willBreakingDeps.length) {
|
|
57
|
+
const tips = [
|
|
58
|
+
...willBreakingDeps.map((dep) => {
|
|
59
|
+
const oldName = import_utils.chalk.yellow(dep);
|
|
60
|
+
const newName = import_utils.chalk.green(
|
|
61
|
+
`${BABEL_TRANSFORM_PREFIX}${dep.replace(
|
|
62
|
+
BABEL_PROPOSAL_PREFIX,
|
|
63
|
+
""
|
|
64
|
+
)}`
|
|
65
|
+
);
|
|
66
|
+
return ` - ${oldName} -> ${newName}`;
|
|
67
|
+
})
|
|
68
|
+
];
|
|
69
|
+
console.log(`
|
|
70
|
+
${import_utils.chalk.bold.yellow("Babel Deprecation Warning")}
|
|
71
|
+
|
|
72
|
+
Babel >= 7.22.0 will remove the following plugins:
|
|
73
|
+
${tips.join("\n")}
|
|
74
|
+
Please use the ${import_utils.chalk.bold.green(
|
|
75
|
+
BABEL_TRANSFORM_PREFIX
|
|
76
|
+
)} prefix instead of ${import_utils.chalk.bold.yellow(
|
|
77
|
+
BABEL_PROPOSAL_PREFIX
|
|
78
|
+
)} prefix and ${import_utils.chalk.blue("update your dependencies and config file")}.
|
|
79
|
+
Refer: https://babeljs.io/blog/2023/05/26/7.22.0#renamed-packages
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {});
|
|
@@ -28,6 +28,8 @@ var import_path = require("path");
|
|
|
28
28
|
var devToolAppDist = (0, import_path.join)(__dirname, "../../../devToolAppDist");
|
|
29
29
|
var assetsDir = (0, import_path.join)(__dirname, "../../../assets");
|
|
30
30
|
var devTool_default = (api) => {
|
|
31
|
+
if (process.env.OKAM)
|
|
32
|
+
return;
|
|
31
33
|
api.addBeforeMiddlewares(async () => {
|
|
32
34
|
const $ = await api.applyPlugins({
|
|
33
35
|
key: "modifyDevToolLoadingHTML",
|
package/dist/features/ssr/ssr.js
CHANGED
|
@@ -87,6 +87,29 @@ var ssr_default = (api) => {
|
|
|
87
87
|
content: `
|
|
88
88
|
import * as React from 'react';
|
|
89
89
|
export { React };
|
|
90
|
+
`
|
|
91
|
+
});
|
|
92
|
+
api.writeTmpFile({
|
|
93
|
+
noPluginDir: true,
|
|
94
|
+
path: "core/serverInsertedHTMLContext.ts",
|
|
95
|
+
content: `
|
|
96
|
+
// Use React.createContext to avoid errors from the RSC checks because
|
|
97
|
+
// it can't be imported directly in Server Components:
|
|
98
|
+
import React from 'react'
|
|
99
|
+
|
|
100
|
+
export type ServerInsertedHTMLHook = (callbacks: () => React.ReactNode) => void;
|
|
101
|
+
// More info: https://github.com/vercel/next.js/pull/40686
|
|
102
|
+
export const ServerInsertedHTMLContext =
|
|
103
|
+
React.createContext<ServerInsertedHTMLHook | null>(null as any);
|
|
104
|
+
|
|
105
|
+
// copy form https://github.com/vercel/next.js/blob/fa076a3a69c9ccf63c9d1e53e7b681aa6dc23db7/packages/next/src/shared/lib/server-inserted-html.tsx#L13
|
|
106
|
+
export function useServerInsertedHTML(callback: () => React.ReactNode): void {
|
|
107
|
+
const addInsertedServerHTMLCallback = React.useContext(ServerInsertedHTMLContext);
|
|
108
|
+
// Should have no effects on client where there's no flush effects provider
|
|
109
|
+
if (addInsertedServerHTMLCallback) {
|
|
110
|
+
addInsertedServerHTMLCallback(callback);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
90
113
|
`
|
|
91
114
|
});
|
|
92
115
|
});
|
|
@@ -564,6 +564,17 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
564
564
|
exports.push(`export { TestBrowser } from './testBrowser';`);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
+
if (api.appData.framework === "react") {
|
|
568
|
+
if (api.config.ssr) {
|
|
569
|
+
exports.push(
|
|
570
|
+
`export { useServerInsertedHTML } from './core/serverInsertedHTMLContext';`
|
|
571
|
+
);
|
|
572
|
+
} else {
|
|
573
|
+
exports.push(
|
|
574
|
+
`export const useServerInsertedHTML: Function = () => {};`
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
567
578
|
exports.push("// plugins");
|
|
568
579
|
const allPlugins = (0, import_fs.readdirSync)(api.paths.absTmpPath).filter(
|
|
569
580
|
(file) => file.startsWith("plugin-")
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ var src_default = () => {
|
|
|
43
43
|
require.resolve("./features/appData/appData"),
|
|
44
44
|
require.resolve("./features/appData/umiInfo"),
|
|
45
45
|
require.resolve("./features/check/check"),
|
|
46
|
+
require.resolve("./features/check/babel722"),
|
|
46
47
|
require.resolve("./features/codeSplitting/codeSplitting"),
|
|
47
48
|
require.resolve("./features/configPlugins/configPlugins"),
|
|
48
49
|
require.resolve("./features/crossorigin/crossorigin"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.73",
|
|
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/
|
|
41
|
-
"@umijs/
|
|
42
|
-
"@umijs/
|
|
43
|
-
"@umijs/bundler-vite": "4.0.
|
|
44
|
-
"@umijs/
|
|
45
|
-
"@umijs/bundler-webpack": "4.0.
|
|
46
|
-
"@umijs/core": "4.0.
|
|
40
|
+
"@umijs/ast": "4.0.73",
|
|
41
|
+
"@umijs/babel-preset-umi": "4.0.73",
|
|
42
|
+
"@umijs/bundler-esbuild": "4.0.73",
|
|
43
|
+
"@umijs/bundler-vite": "4.0.73",
|
|
44
|
+
"@umijs/bundler-utils": "4.0.73",
|
|
45
|
+
"@umijs/bundler-webpack": "4.0.73",
|
|
46
|
+
"@umijs/core": "4.0.73",
|
|
47
47
|
"@umijs/did-you-know": "1.0.3",
|
|
48
|
-
"@umijs/mfsu": "4.0.
|
|
49
|
-
"@umijs/plugin-run": "4.0.
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/
|
|
52
|
-
"@umijs/
|
|
53
|
-
"@umijs/
|
|
54
|
-
"@umijs/
|
|
48
|
+
"@umijs/mfsu": "4.0.73",
|
|
49
|
+
"@umijs/plugin-run": "4.0.73",
|
|
50
|
+
"@umijs/server": "4.0.73",
|
|
51
|
+
"@umijs/renderer-react": "4.0.73",
|
|
52
|
+
"@umijs/ui": "3.0.1",
|
|
53
|
+
"@umijs/utils": "4.0.73",
|
|
54
|
+
"@umijs/zod2ts": "4.0.73"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@manypkg/get-packages": "1.1.3",
|
package/templates/server.tpl
CHANGED
|
@@ -2,6 +2,7 @@ import { getClientRootComponent } from '{{{ serverRendererPath }}}';
|
|
|
2
2
|
import { getRoutes } from './core/route';
|
|
3
3
|
import { createHistory as createClientHistory } from './core/history';
|
|
4
4
|
import { getPlugins as getClientPlugins } from './core/plugin';
|
|
5
|
+
import { ServerInsertedHTMLContext } from './core/serverInsertedHTMLContext';
|
|
5
6
|
import { PluginManager } from '{{{ umiPluginPath }}}';
|
|
6
7
|
import createRequestHandler, { createMarkupGenerator } from '{{{ umiServerPath }}}';
|
|
7
8
|
|
|
@@ -50,6 +51,7 @@ const createOpts = {
|
|
|
50
51
|
getClientRootComponent,
|
|
51
52
|
helmetContext,
|
|
52
53
|
createHistory,
|
|
54
|
+
ServerInsertedHTMLContext,
|
|
53
55
|
};
|
|
54
56
|
const requestHandler = createRequestHandler(createOpts);
|
|
55
57
|
|