@umijs/preset-umi 4.0.87 → 4.0.89
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/features/appData/appData.js +1 -0
- package/dist/features/legacy/legacy.js +3 -1
- package/dist/features/overrides/compileLess.d.ts +7 -1
- package/dist/features/overrides/compileLess.js +14 -6
- package/dist/features/overrides/{compileLess.manullytest.js → compileLess.testScript.js} +25 -14
- package/dist/features/overrides/overrides.js +10 -7
- package/dist/features/overrides/transform.js +3 -1
- package/dist/features/ssr/ssr.js +19 -0
- package/dist/features/ssr/webpack/webpack.js +5 -3
- package/dist/features/tmpFiles/routes.js +1 -0
- package/dist/features/tmpFiles/tmpFiles.js +16 -8
- package/dist/features/vite/vite.js +4 -0
- package/package.json +16 -16
- /package/dist/features/overrides/{compileLess.manullytest.d.ts → compileLess.testScript.d.ts} +0 -0
|
@@ -86,6 +86,7 @@ var legacy_default = (api) => {
|
|
|
86
86
|
api.modifyConfig({
|
|
87
87
|
stage: Number.MAX_SAFE_INTEGER,
|
|
88
88
|
fn: (memo) => {
|
|
89
|
+
var _a, _b;
|
|
89
90
|
const { userConfig } = api;
|
|
90
91
|
const { buildOnly = true, nodeModulesTransform = true } = pluginConfig;
|
|
91
92
|
if (api.env === import_types.Env.development) {
|
|
@@ -116,9 +117,10 @@ var legacy_default = (api) => {
|
|
|
116
117
|
memo.srcTranspiler = import_types.Transpiler.babel;
|
|
117
118
|
memo.jsMinifier = import_types.JSMinifier.terser;
|
|
118
119
|
memo.cssMinifier = import_types.CSSMinifier.cssnano;
|
|
120
|
+
const ieTarget = ((_a = userConfig.targets) == null ? void 0 : _a.ie) || ((_b = api.config.targets) == null ? void 0 : _b.ie) || 11;
|
|
119
121
|
memo.targets = {
|
|
120
122
|
...userConfig.targets,
|
|
121
|
-
ie:
|
|
123
|
+
ie: ieTarget
|
|
122
124
|
};
|
|
123
125
|
import_utils.logger.info(
|
|
124
126
|
`${legacyModeLabel} is enabled, we automatically modify the ${[
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export declare function compileLess(
|
|
1
|
+
export declare function compileLess(opts: {
|
|
2
|
+
lessContent: string;
|
|
3
|
+
filePath: string;
|
|
4
|
+
modifyVars: Record<string, string>;
|
|
5
|
+
alias: Record<string, string>;
|
|
6
|
+
targetPath: string;
|
|
7
|
+
}): Promise<string>;
|
|
@@ -33,14 +33,22 @@ __export(compileLess_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(compileLess_exports);
|
|
35
35
|
var import_less = __toESM(require("@umijs/bundler-utils/compiled/less"));
|
|
36
|
-
|
|
36
|
+
var import_utils = require("@umijs/utils");
|
|
37
|
+
async function compileLess(opts) {
|
|
38
|
+
const {
|
|
39
|
+
lessContent,
|
|
40
|
+
filePath,
|
|
41
|
+
modifyVars = {},
|
|
42
|
+
alias = {},
|
|
43
|
+
targetPath
|
|
44
|
+
} = opts;
|
|
45
|
+
const resolvePlugin = new (require("less-plugin-resolve"))({
|
|
46
|
+
aliases: alias,
|
|
47
|
+
urlRewriteTargetPath: (0, import_utils.winPath)(targetPath)
|
|
48
|
+
});
|
|
37
49
|
const result = await import_less.default.render(lessContent, {
|
|
38
50
|
filename: filePath,
|
|
39
|
-
plugins: [
|
|
40
|
-
new (require("less-plugin-resolve"))({
|
|
41
|
-
aliases: alias
|
|
42
|
-
})
|
|
43
|
-
],
|
|
51
|
+
plugins: [resolvePlugin],
|
|
44
52
|
javascriptEnabled: true,
|
|
45
53
|
modifyVars
|
|
46
54
|
});
|
|
@@ -21,42 +21,53 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
mod
|
|
22
22
|
));
|
|
23
23
|
|
|
24
|
-
// src/features/overrides/compileLess.
|
|
25
|
-
var import_assert = __toESM(require("assert"));
|
|
24
|
+
// src/features/overrides/compileLess.testScript.ts
|
|
26
25
|
var import_fs = __toESM(require("fs"));
|
|
27
26
|
var import_path = require("path");
|
|
28
27
|
var import_compileLess = require("./compileLess");
|
|
29
28
|
var fixturesDir = (0, import_path.join)(__dirname, "../../../fixtures");
|
|
30
|
-
|
|
29
|
+
var run = async () => {
|
|
31
30
|
const filePath = (0, import_path.join)(fixturesDir, "overrides/less/index.less");
|
|
31
|
+
const targetPath = (0, import_path.join)(fixturesDir, "overrides/less/output/index.css");
|
|
32
32
|
const modifyVars = {
|
|
33
33
|
"primary-color": "#1DA57A"
|
|
34
34
|
};
|
|
35
35
|
const alias = {
|
|
36
36
|
barbar: (0, import_path.join)(filePath, "../node_modules/bar")
|
|
37
37
|
};
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const content = import_fs.default.readFileSync(filePath, "utf-8");
|
|
39
|
+
const result = await (0, import_compileLess.compileLess)({
|
|
40
|
+
lessContent: content,
|
|
40
41
|
filePath,
|
|
41
42
|
modifyVars,
|
|
42
|
-
alias
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
`
|
|
43
|
+
alias,
|
|
44
|
+
targetPath
|
|
45
|
+
});
|
|
46
|
+
const expectContained = `
|
|
47
47
|
.bar {
|
|
48
48
|
color: red;
|
|
49
49
|
}
|
|
50
50
|
.foo {
|
|
51
51
|
color: red;
|
|
52
52
|
}
|
|
53
|
+
.img {
|
|
54
|
+
background: url('../assets/img.png');
|
|
55
|
+
}
|
|
53
56
|
.a {
|
|
54
57
|
aaa: green;
|
|
55
58
|
bbb: #1DA57A;
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
.img {
|
|
61
|
+
border-image: url('../assets/img.png');
|
|
62
|
+
}
|
|
63
|
+
`.trim();
|
|
64
|
+
if (!result.includes(expectContained)) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`result not contains the expect content, result: ${result}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
run().catch((e) => {
|
|
61
71
|
console.error(e);
|
|
72
|
+
process.exit(1);
|
|
62
73
|
});
|
|
@@ -40,22 +40,25 @@ var overrides_default = (api) => {
|
|
|
40
40
|
let content = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
41
41
|
if (content === cachedContent)
|
|
42
42
|
return;
|
|
43
|
+
const subPath = "core/overrides.css";
|
|
44
|
+
const targetPath = (0, import_path.join)(api.paths.absTmpPath, subPath);
|
|
43
45
|
const isLess = filePath.endsWith(".less");
|
|
44
46
|
if (isLess) {
|
|
45
|
-
content = await (0, import_compileLess.compileLess)(
|
|
46
|
-
content,
|
|
47
|
+
content = await (0, import_compileLess.compileLess)({
|
|
48
|
+
lessContent: content,
|
|
47
49
|
filePath,
|
|
48
|
-
{
|
|
50
|
+
modifyVars: {
|
|
49
51
|
...api.config.theme,
|
|
50
52
|
...(_a = api.config.lessLoader) == null ? void 0 : _a.modifyVars
|
|
51
53
|
},
|
|
52
|
-
api.config.alias
|
|
53
|
-
|
|
54
|
+
alias: api.config.alias,
|
|
55
|
+
targetPath
|
|
56
|
+
});
|
|
54
57
|
}
|
|
55
58
|
content = await (0, import_transform.transform)(content, filePath);
|
|
56
59
|
api.writeTmpFile({
|
|
57
|
-
path:
|
|
58
|
-
content,
|
|
60
|
+
path: subPath,
|
|
61
|
+
content: content || "/* empty */",
|
|
59
62
|
noPluginDir: true
|
|
60
63
|
});
|
|
61
64
|
cachedContent = content;
|
|
@@ -77,7 +77,9 @@ async function transform(cssContent, filePath) {
|
|
|
77
77
|
const result = await require("postcss")([
|
|
78
78
|
selectorPlugin,
|
|
79
79
|
importPlugin
|
|
80
|
-
]).process(cssContent, {
|
|
80
|
+
]).process(cssContent, {
|
|
81
|
+
from: "overrides.css"
|
|
82
|
+
});
|
|
81
83
|
return result.css;
|
|
82
84
|
}
|
|
83
85
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/features/ssr/ssr.js
CHANGED
|
@@ -80,6 +80,10 @@ var ssr_default = (api) => {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
]);
|
|
83
|
+
const serverPackagePath = (0, import_path.dirname)(
|
|
84
|
+
require.resolve("@umijs/server/package.json")
|
|
85
|
+
);
|
|
86
|
+
const ssrTypesPath = (0, import_path.join)(serverPackagePath, "./dist/types");
|
|
83
87
|
api.onGenerateFiles(() => {
|
|
84
88
|
api.writeTmpFile({
|
|
85
89
|
noPluginDir: true,
|
|
@@ -110,6 +114,21 @@ export function useServerInsertedHTML(callback: () => React.ReactNode): void {
|
|
|
110
114
|
addInsertedServerHTMLCallback(callback);
|
|
111
115
|
}
|
|
112
116
|
}
|
|
117
|
+
`
|
|
118
|
+
});
|
|
119
|
+
api.writeTmpFile({
|
|
120
|
+
path: "types.d.ts",
|
|
121
|
+
content: `
|
|
122
|
+
export type {
|
|
123
|
+
// server loader
|
|
124
|
+
IServerLoaderArgs,
|
|
125
|
+
UmiRequest,
|
|
126
|
+
ServerLoader,
|
|
127
|
+
// metadata loader
|
|
128
|
+
MetadataLoader,
|
|
129
|
+
IMetadata,
|
|
130
|
+
IMetaTag,
|
|
131
|
+
} from '${(0, import_utils.winPath)(ssrTypesPath)}'
|
|
113
132
|
`
|
|
114
133
|
});
|
|
115
134
|
});
|
|
@@ -33,10 +33,10 @@ __export(webpack_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(webpack_exports);
|
|
35
35
|
var bundlerWebpack = __toESM(require("@umijs/bundler-webpack"));
|
|
36
|
+
var import_types = require("@umijs/bundler-webpack/dist/types");
|
|
36
37
|
var import_utils = require("@umijs/utils");
|
|
37
38
|
var import_path = require("path");
|
|
38
39
|
var import_utils2 = require("../utils");
|
|
39
|
-
var import_types = require("@umijs/bundler-webpack/dist/types");
|
|
40
40
|
var build2 = async (api, opts) => {
|
|
41
41
|
import_utils.logger.wait("[SSR] Compiling...");
|
|
42
42
|
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -59,8 +59,10 @@ var build2 = async (api, opts) => {
|
|
|
59
59
|
memo.target("node");
|
|
60
60
|
memo.name("umi");
|
|
61
61
|
memo.devtool(false);
|
|
62
|
-
memo.output.path((0, import_path.dirname)(absOutputFile)).filename(
|
|
63
|
-
useHash ? "
|
|
62
|
+
memo.output.path((0, import_path.dirname)(absOutputFile)).filename(
|
|
63
|
+
useHash ? "[name].[contenthash:8].server.js" : "[name].server.js"
|
|
64
|
+
).chunkFilename(
|
|
65
|
+
useHash ? "[name].[contenthash:8].server.js" : "[name].server.js"
|
|
64
66
|
).libraryTarget("commonjs2");
|
|
65
67
|
memo.plugins.delete("progress-plugin");
|
|
66
68
|
memo.optimization.minimize(false);
|
|
@@ -156,6 +156,7 @@ async function getRoutes(opts) {
|
|
|
156
156
|
}) : [];
|
|
157
157
|
if (enableSSR) {
|
|
158
158
|
routes[id].hasServerLoader = exports.includes("serverLoader");
|
|
159
|
+
routes[id].hasMetadataLoader = exports.includes("metadataLoader");
|
|
159
160
|
}
|
|
160
161
|
if (enableClientLoader && exports.includes("clientLoader")) {
|
|
161
162
|
routes[id].clientLoader = `clientLoaders['${id}']`;
|
|
@@ -539,6 +539,8 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
539
539
|
})
|
|
540
540
|
);
|
|
541
541
|
const exports = [];
|
|
542
|
+
const beforeExports = [];
|
|
543
|
+
const afterExports = [];
|
|
542
544
|
const exportMembers = ["default"];
|
|
543
545
|
exports.push("// @umijs/renderer-*");
|
|
544
546
|
exports.push(
|
|
@@ -547,7 +549,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
547
549
|
exportMembers
|
|
548
550
|
})).join(", ")} } from '${rendererPath}';`
|
|
549
551
|
);
|
|
550
|
-
exports.push(`export type {
|
|
552
|
+
exports.push(`export type { History } from '${rendererPath}'`);
|
|
551
553
|
exports.push("// umi/client/client/plugin");
|
|
552
554
|
const umiPluginPath = (0, import_utils.winPath)((0, import_path.join)(umiDir, "client/client/plugin.js"));
|
|
553
555
|
exports.push(
|
|
@@ -573,10 +575,14 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
573
575
|
if (api.config.test !== false && api.appData.framework === "react") {
|
|
574
576
|
if (process.env.NODE_ENV === "test" || // development is for TestBrowser's type
|
|
575
577
|
process.env.NODE_ENV === "development") {
|
|
576
|
-
|
|
578
|
+
afterExports.push(
|
|
579
|
+
`// test`,
|
|
580
|
+
`export { TestBrowser } from './testBrowser';`
|
|
581
|
+
);
|
|
577
582
|
}
|
|
578
583
|
}
|
|
579
584
|
if (api.appData.framework === "react") {
|
|
585
|
+
exports.push("// react ssr");
|
|
580
586
|
if (api.config.ssr) {
|
|
581
587
|
exports.push(
|
|
582
588
|
`export { useServerInsertedHTML } from './core/serverInsertedHTMLContext';`
|
|
@@ -587,7 +593,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
587
593
|
);
|
|
588
594
|
}
|
|
589
595
|
}
|
|
590
|
-
|
|
596
|
+
beforeExports.push("// plugins");
|
|
591
597
|
const allPlugins = (0, import_fs.readdirSync)(api.paths.absTmpPath).filter(
|
|
592
598
|
(file) => file.startsWith("plugin-")
|
|
593
599
|
);
|
|
@@ -609,19 +615,19 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
609
615
|
exportMembers
|
|
610
616
|
});
|
|
611
617
|
if (pluginExports.length) {
|
|
612
|
-
|
|
618
|
+
beforeExports.push(
|
|
613
619
|
`export { ${pluginExports.join(", ")} } from '${(0, import_utils.winPath)(
|
|
614
620
|
(0, import_path.join)(api.paths.absTmpPath, plugin)
|
|
615
621
|
)}';`
|
|
616
622
|
);
|
|
617
623
|
}
|
|
618
624
|
}
|
|
619
|
-
|
|
625
|
+
beforeExports.push("// plugins types.d.ts");
|
|
620
626
|
for (const plugin of allPlugins) {
|
|
621
627
|
const file = (0, import_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, plugin, "types.d.ts"));
|
|
622
628
|
if ((0, import_fs.existsSync)(file)) {
|
|
623
629
|
const noSuffixFile = file.replace(/\.ts$/, "");
|
|
624
|
-
|
|
630
|
+
beforeExports.push(`export * from '${noSuffixFile}';`);
|
|
625
631
|
}
|
|
626
632
|
}
|
|
627
633
|
let pluginIndex = 0;
|
|
@@ -652,7 +658,9 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
652
658
|
runtimeConfigType
|
|
653
659
|
}
|
|
654
660
|
});
|
|
655
|
-
|
|
661
|
+
beforeExports.unshift(
|
|
662
|
+
// `app.ts` should be in the first, otherwise it will be circular dependency
|
|
663
|
+
`// defineApp`,
|
|
656
664
|
`export { defineApp } from './core/defineApp'`,
|
|
657
665
|
// https://javascript.plainenglish.io/leveraging-type-only-imports-and-exports-with-typescript-3-8-5c1be8bd17fb
|
|
658
666
|
`export type { RuntimeConfig } from './core/defineApp'`
|
|
@@ -660,7 +668,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
660
668
|
api.writeTmpFile({
|
|
661
669
|
noPluginDir: true,
|
|
662
670
|
path: "exports.ts",
|
|
663
|
-
content: exports.join("\n")
|
|
671
|
+
content: [...beforeExports, ...exports, ...afterExports].join("\n")
|
|
664
672
|
});
|
|
665
673
|
},
|
|
666
674
|
stage: 1e4
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.89",
|
|
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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"enhanced-resolve": "5.9.3",
|
|
31
31
|
"fast-glob": "3.2.12",
|
|
32
32
|
"html-webpack-plugin": "5.5.0",
|
|
33
|
-
"less-plugin-resolve": "1.0.
|
|
33
|
+
"less-plugin-resolve": "1.0.2",
|
|
34
34
|
"path-to-regexp": "1.7.0",
|
|
35
35
|
"postcss": "^8.4.21",
|
|
36
36
|
"postcss-prefix-selector": "1.16.0",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"react-router": "6.3.0",
|
|
40
40
|
"react-router-dom": "6.3.0",
|
|
41
41
|
"regenerator-runtime": "0.13.11",
|
|
42
|
-
"@umijs/ast": "4.0.
|
|
43
|
-
"@umijs/bundler-
|
|
44
|
-
"@umijs/bundler-
|
|
42
|
+
"@umijs/ast": "4.0.89",
|
|
43
|
+
"@umijs/bundler-esbuild": "4.0.89",
|
|
44
|
+
"@umijs/bundler-utils": "4.0.89",
|
|
45
|
+
"@umijs/babel-preset-umi": "4.0.89",
|
|
46
|
+
"@umijs/bundler-vite": "4.0.89",
|
|
47
|
+
"@umijs/core": "4.0.89",
|
|
48
|
+
"@umijs/mfsu": "4.0.89",
|
|
49
|
+
"@umijs/renderer-react": "4.0.89",
|
|
50
|
+
"@umijs/bundler-webpack": "4.0.89",
|
|
51
|
+
"@umijs/plugin-run": "4.0.89",
|
|
52
|
+
"@umijs/zod2ts": "4.0.89",
|
|
53
|
+
"@umijs/utils": "4.0.89",
|
|
54
|
+
"@umijs/server": "4.0.89",
|
|
45
55
|
"@umijs/did-you-know": "1.0.3",
|
|
46
|
-
"@umijs/
|
|
47
|
-
"@umijs/bundler-esbuild": "4.0.87",
|
|
48
|
-
"@umijs/babel-preset-umi": "4.0.87",
|
|
49
|
-
"@umijs/mfsu": "4.0.87",
|
|
50
|
-
"@umijs/bundler-webpack": "4.0.87",
|
|
51
|
-
"@umijs/ui": "3.0.1",
|
|
52
|
-
"@umijs/renderer-react": "4.0.87",
|
|
53
|
-
"@umijs/utils": "4.0.87",
|
|
54
|
-
"@umijs/server": "4.0.87",
|
|
55
|
-
"@umijs/zod2ts": "4.0.87",
|
|
56
|
-
"@umijs/plugin-run": "4.0.87"
|
|
56
|
+
"@umijs/ui": "3.0.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@manypkg/get-packages": "1.1.3",
|
/package/dist/features/overrides/{compileLess.manullytest.d.ts → compileLess.testScript.d.ts}
RENAMED
|
File without changes
|