@umijs/preset-umi 4.0.24 → 4.0.26
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/depBuildWorker/depBuildWorker.js +1 -0
- package/dist/features/apiRoute/request.d.ts +1 -0
- package/dist/features/appData/appData.js +8 -3
- package/dist/features/check/check.js +8 -4
- package/dist/features/configPlugins/configPlugins.js +2 -1
- package/dist/features/overrides/overrides.d.ts +4 -0
- package/dist/features/overrides/overrides.js +61 -0
- package/dist/features/tmpFiles/routes.js +1 -1
- package/dist/features/tmpFiles/tmpFiles.js +5 -1
- package/dist/index.js +1 -0
- package/dist/libs/folderCache/AutoUpdateSourceCodeCache.d.ts +1 -0
- package/dist/libs/folderCache/AutoUpdateSourceCodeCache.js +16 -17
- package/package.json +13 -12
|
@@ -24,6 +24,7 @@ var import_path = require("path");
|
|
|
24
24
|
var import_worker_threads = require("worker_threads");
|
|
25
25
|
var import_depBuilder = require("./depBuilder");
|
|
26
26
|
var import_getConfig = require("./getConfig");
|
|
27
|
+
(0, import_utils.setNoDeprecation)();
|
|
27
28
|
if (import_worker_threads.isMainThread) {
|
|
28
29
|
throw Error("MFSU-eager builder can only be called in a worker thread");
|
|
29
30
|
}
|
|
@@ -30,6 +30,7 @@ var import_ini = require("../../../compiled/ini");
|
|
|
30
30
|
var import_os_locale = require("../../../compiled/os-locale");
|
|
31
31
|
var import_watch = require("../../commands/dev/watch");
|
|
32
32
|
var import_scan = require("../../libs/scan");
|
|
33
|
+
var import_overrides = require("../overrides/overrides");
|
|
33
34
|
var import_routes = require("../tmpFiles/routes");
|
|
34
35
|
var appData_default = (api) => {
|
|
35
36
|
api.modifyAppData(async (memo) => {
|
|
@@ -67,9 +68,10 @@ var appData_default = (api) => {
|
|
|
67
68
|
memo.appJS = await getAppJsInfo();
|
|
68
69
|
memo.locale = await (0, import_os_locale.osLocale)();
|
|
69
70
|
memo.vite = api.config.vite ? {} : void 0;
|
|
70
|
-
const { globalCSS, globalJS } = getGlobalFiles();
|
|
71
|
+
const { globalCSS, globalJS, overridesCSS } = getGlobalFiles();
|
|
71
72
|
memo.globalCSS = globalCSS;
|
|
72
73
|
memo.globalJS = globalJS;
|
|
74
|
+
memo.overridesCSS = overridesCSS;
|
|
73
75
|
const gitDir = findGitDir(api.paths.cwd);
|
|
74
76
|
if (gitDir) {
|
|
75
77
|
const git = {};
|
|
@@ -104,9 +106,10 @@ var appData_default = (api) => {
|
|
|
104
106
|
async fn(args) {
|
|
105
107
|
if (!args.isFirstTime) {
|
|
106
108
|
api.appData.appJS = await getAppJsInfo();
|
|
107
|
-
const { globalCSS, globalJS } = getGlobalFiles();
|
|
109
|
+
const { globalCSS, globalJS, overridesCSS } = getGlobalFiles();
|
|
108
110
|
api.appData.globalCSS = globalCSS;
|
|
109
111
|
api.appData.globalJS = globalJS;
|
|
112
|
+
api.appData.overridesCSS = overridesCSS;
|
|
110
113
|
}
|
|
111
114
|
},
|
|
112
115
|
stage: Number.NEGATIVE_INFINITY
|
|
@@ -157,9 +160,11 @@ var appData_default = (api) => {
|
|
|
157
160
|
};
|
|
158
161
|
const globalCSS = (0, import_watch.expandCSSPaths)((0, import_path.join)(absSrcPath, "global")).reduce(existsAndPushFile, []);
|
|
159
162
|
const globalJS = (0, import_watch.expandJSPaths)((0, import_path.join)(absSrcPath, "global")).reduce(existsAndPushFile, []);
|
|
163
|
+
const overridesCSS = [(0, import_overrides.getOverridesCSS)(api.paths.absSrcPath)].filter(Boolean);
|
|
160
164
|
return {
|
|
161
165
|
globalCSS,
|
|
162
|
-
globalJS
|
|
166
|
+
globalJS,
|
|
167
|
+
overridesCSS
|
|
163
168
|
};
|
|
164
169
|
}
|
|
165
170
|
};
|
|
@@ -44,13 +44,17 @@ var check_default = (api) => {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
api.onCheckCode(({ CodeFrameError, ...args }) => {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
args.imports.forEach(({ source, loc }) => {
|
|
48
|
+
if (["cnpm", "tnpm"].includes(api.appData.npmClient)) {
|
|
49
49
|
if (!isAbsolutePath(source) && /@\d/.test(source)) {
|
|
50
50
|
throw new CodeFrameError(`${source} is not allowed to import.`, loc);
|
|
51
51
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
52
|
+
}
|
|
53
|
+
if (!isAbsolutePath(source) && /\/\.umi(-(test|production))?\//.test(source)) {
|
|
54
|
+
const { importSource } = api.appData.umi;
|
|
55
|
+
throw new CodeFrameError(`${source} includes /.umi/, /.umi-test/ or /.umi-production/. It's not allowed to import. Please import from ${importSource} or the corresponding plugin.`, loc);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
54
58
|
});
|
|
55
59
|
api.onCheckConfig(({ config }) => {
|
|
56
60
|
if (config.publicPath.startsWith("./") && api.env === "development") {
|
|
@@ -76,7 +76,8 @@ var configPlugins_default = (api) => {
|
|
|
76
76
|
base: "/",
|
|
77
77
|
history: { type: "browser" },
|
|
78
78
|
svgr: {},
|
|
79
|
-
ignoreMomentLocale: true
|
|
79
|
+
ignoreMomentLocale: true,
|
|
80
|
+
mfsu: { strategy: "eager" }
|
|
80
81
|
};
|
|
81
82
|
const bundleSchemas = api.config.vite ? (0, import_schema.getSchemas)() : (0, import_schema2.getSchemas)();
|
|
82
83
|
const extraSchemas = (0, import_schema3.getSchemas)();
|
|
@@ -0,0 +1,61 @@
|
|
|
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/overrides/overrides.ts
|
|
20
|
+
var overrides_exports = {};
|
|
21
|
+
__export(overrides_exports, {
|
|
22
|
+
default: () => overrides_default,
|
|
23
|
+
getOverridesCSS: () => getOverridesCSS
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(overrides_exports);
|
|
26
|
+
var import_utils = require("@umijs/utils");
|
|
27
|
+
var import_fs = require("fs");
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_watch = require("../../commands/dev/watch");
|
|
30
|
+
function getOverridesCSS(absSrcPath) {
|
|
31
|
+
return (0, import_watch.expandCSSPaths)((0, import_path.join)(absSrcPath, "overrides")).find(import_fs.existsSync);
|
|
32
|
+
}
|
|
33
|
+
var overrides_default = (api) => {
|
|
34
|
+
api.modifyConfig((memo) => {
|
|
35
|
+
if (getOverridesCSS(api.paths.absSrcPath)) {
|
|
36
|
+
memo.extraPostCSSPlugins ?? (memo.extraPostCSSPlugins = []);
|
|
37
|
+
memo.extraPostCSSPlugins.push([
|
|
38
|
+
require("postcss-prefix-selector")({
|
|
39
|
+
prefix: "#fake",
|
|
40
|
+
transform(_p, selector, _ps, filePath) {
|
|
41
|
+
const isOverridesFile = (0, import_utils.winPath)(api.appData.overridesCSS[0]) === (0, import_utils.winPath)(filePath);
|
|
42
|
+
if (isOverridesFile && !new RegExp(`^#${api.config.mountElementId}([:[\\s]|$)`).test(selector)) {
|
|
43
|
+
if (selector === "html") {
|
|
44
|
+
return `html:first-child`;
|
|
45
|
+
} else if (selector === "body") {
|
|
46
|
+
return `* + body`;
|
|
47
|
+
}
|
|
48
|
+
return `#${api.config.mountElementId} ${selector}`;
|
|
49
|
+
}
|
|
50
|
+
return selector;
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
return memo;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getOverridesCSS
|
|
61
|
+
});
|
|
@@ -198,7 +198,7 @@ function lastSlash(str) {
|
|
|
198
198
|
return str[str.length - 1] === "/" ? str : `${str}/`;
|
|
199
199
|
}
|
|
200
200
|
function componentToChunkName(component, cwd) {
|
|
201
|
-
return typeof component === "string" ? component.replace(new RegExp(`^${import_utils.lodash.escapeRegExp(lastSlash((0, import_utils.winPath)(cwd || "/")))}`), "").replace(/^.(\/|\\)/, "").replace(/(\/|\\)/g, "__").replace(/\.jsx?$/, "").replace(/\.tsx?$/, "").replace(/\.vue?$/, "").replace(/^src__/, "").replace(/\.\.__/g, "").replace(/[\[\]]/g, "").replace(/^.umi-production__/, "t__").replace(/^pages__/, "p__") : "";
|
|
201
|
+
return typeof component === "string" ? component.replace(new RegExp(`^${import_utils.lodash.escapeRegExp(lastSlash((0, import_utils.winPath)(cwd || "/")))}`), "").replace(/^.(\/|\\)/, "").replace(/(\/|\\)/g, "__").replace(/\.jsx?$/, "").replace(/\.tsx?$/, "").replace(/\.vue?$/, "").replace(/^src__/, "").replace(/\.\.__/g, "").replace(/[\[\]]/g, "").replace(/^.umi-production__/, "t__").replace(/^\./, "").replace(/^pages__/, "p__") : "";
|
|
202
202
|
}
|
|
203
203
|
// Annotate the CommonJS export names for ESM import in node:
|
|
204
204
|
0 && (module.exports = {
|
|
@@ -271,7 +271,11 @@ declare module '*.txt' {
|
|
|
271
271
|
})).join("\n"),
|
|
272
272
|
imports: (0, import_importsToStr.importsToStr)(await api.applyPlugins({
|
|
273
273
|
key: "addEntryImports",
|
|
274
|
-
initialValue: [
|
|
274
|
+
initialValue: [
|
|
275
|
+
api.appData.overridesCSS.length && {
|
|
276
|
+
source: api.appData.overridesCSS[0]
|
|
277
|
+
}
|
|
278
|
+
].filter(Boolean)
|
|
275
279
|
})).join("\n"),
|
|
276
280
|
basename: api.config.base,
|
|
277
281
|
historyType: api.config.history.type,
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var src_default = () => {
|
|
|
42
42
|
require.resolve("./features/favicons/favicons"),
|
|
43
43
|
require.resolve("./features/mock/mock"),
|
|
44
44
|
require.resolve("./features/mpa/mpa"),
|
|
45
|
+
require.resolve("./features/overrides/overrides"),
|
|
45
46
|
require.resolve("./features/polyfill/polyfill"),
|
|
46
47
|
require.resolve("./features/polyfill/publicPathPolyfill"),
|
|
47
48
|
require.resolve("./features/routePrefetch/routePrefetch"),
|
|
@@ -35,20 +35,25 @@ var import_AutoUpdateFolderCache = require("./AutoUpdateFolderCache");
|
|
|
35
35
|
var AutoUpdateSrcCodeCache = class {
|
|
36
36
|
constructor(opts) {
|
|
37
37
|
this.listeners = [];
|
|
38
|
+
this.ignores = [
|
|
39
|
+
"**/*.d.ts",
|
|
40
|
+
"**/*.test.{js,ts,jsx,tsx}",
|
|
41
|
+
"**/.umi-production/**",
|
|
42
|
+
"**/.umi-test/**",
|
|
43
|
+
"**/node_modules/**",
|
|
44
|
+
"**/.git/**",
|
|
45
|
+
"**/dist/**",
|
|
46
|
+
"**/coverage/**",
|
|
47
|
+
"**/jest.config.{ts,js}",
|
|
48
|
+
"**/jest-setup.{ts,js}"
|
|
49
|
+
];
|
|
38
50
|
this.srcPath = opts.cwd;
|
|
39
51
|
this.cachePath = opts.cachePath;
|
|
40
52
|
this.folderCache = new import_AutoUpdateFolderCache.AutoUpdateFolderCache({
|
|
41
53
|
cwd: this.srcPath,
|
|
42
54
|
exts: ["ts", "js", "jsx", "tsx"],
|
|
43
|
-
ignored:
|
|
44
|
-
|
|
45
|
-
"**/*.test.{js,ts,jsx,tsx}",
|
|
46
|
-
"**/.umi-production/**",
|
|
47
|
-
"**/.umi-test/**",
|
|
48
|
-
"**/node_modules/**",
|
|
49
|
-
"**/.git/**"
|
|
50
|
-
],
|
|
51
|
-
debouncedTimeout: 500,
|
|
55
|
+
ignored: this.ignores,
|
|
56
|
+
debouncedTimeout: 200,
|
|
52
57
|
filesLoader: async (files) => {
|
|
53
58
|
const loaded = {};
|
|
54
59
|
await this.batchProcess(files);
|
|
@@ -72,15 +77,9 @@ var AutoUpdateSrcCodeCache = class {
|
|
|
72
77
|
}
|
|
73
78
|
async initFileList() {
|
|
74
79
|
const start = Date.now();
|
|
75
|
-
const files = await (0, import_fast_glob.default)((0, import_path.join)(this.srcPath, "**", "*.{ts,js,jsx,tsx}"), {
|
|
80
|
+
const files = await (0, import_fast_glob.default)((0, import_utils.winPath)((0, import_path.join)(this.srcPath, "**", "*.{ts,js,jsx,tsx}")), {
|
|
76
81
|
dot: true,
|
|
77
|
-
ignore:
|
|
78
|
-
"**/*.d.ts",
|
|
79
|
-
"**/*.test.{js,ts,jsx,tsx}",
|
|
80
|
-
"**/.umi-production/**",
|
|
81
|
-
"**/node_modules/**",
|
|
82
|
-
"**/.git/**"
|
|
83
|
-
]
|
|
82
|
+
ignore: this.ignores
|
|
84
83
|
});
|
|
85
84
|
import_utils.logger.debug("[MFSU][eager] fast-glob costs", Date.now() - start);
|
|
86
85
|
return files;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.26",
|
|
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",
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"test": "umi-scripts jest-turbo"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@umijs/ast": "4.0.
|
|
29
|
-
"@umijs/babel-preset-umi": "4.0.
|
|
30
|
-
"@umijs/bundler-utils": "4.0.
|
|
31
|
-
"@umijs/bundler-vite": "4.0.
|
|
32
|
-
"@umijs/bundler-webpack": "4.0.
|
|
33
|
-
"@umijs/core": "4.0.
|
|
28
|
+
"@umijs/ast": "4.0.26",
|
|
29
|
+
"@umijs/babel-preset-umi": "4.0.26",
|
|
30
|
+
"@umijs/bundler-utils": "4.0.26",
|
|
31
|
+
"@umijs/bundler-vite": "4.0.26",
|
|
32
|
+
"@umijs/bundler-webpack": "4.0.26",
|
|
33
|
+
"@umijs/core": "4.0.26",
|
|
34
34
|
"@umijs/did-you-know": "^1.0.0",
|
|
35
35
|
"@umijs/history": "5.3.1",
|
|
36
|
-
"@umijs/mfsu": "4.0.
|
|
37
|
-
"@umijs/plugin-run": "4.0.
|
|
38
|
-
"@umijs/renderer-react": "4.0.
|
|
39
|
-
"@umijs/server": "4.0.
|
|
40
|
-
"@umijs/utils": "4.0.
|
|
36
|
+
"@umijs/mfsu": "4.0.26",
|
|
37
|
+
"@umijs/plugin-run": "4.0.26",
|
|
38
|
+
"@umijs/renderer-react": "4.0.26",
|
|
39
|
+
"@umijs/server": "4.0.26",
|
|
40
|
+
"@umijs/utils": "4.0.26",
|
|
41
41
|
"click-to-react-component": "^1.0.8",
|
|
42
42
|
"core-js": "3.22.4",
|
|
43
43
|
"current-script-polyfill": "1.0.0",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"html-webpack-plugin": "5.5.0",
|
|
47
47
|
"magic-string": "0.26.2",
|
|
48
48
|
"path-to-regexp": "1.7.0",
|
|
49
|
+
"postcss-prefix-selector": "1.16.0",
|
|
49
50
|
"react": "18.1.0",
|
|
50
51
|
"react-dom": "18.1.0",
|
|
51
52
|
"react-router": "6.3.0",
|