@umijs/preset-umi 4.0.50 → 4.0.52
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/config/remove.js +4 -0
- package/dist/commands/config/set.js +4 -0
- package/dist/commands/dev/depBuildWorker/depBuildWorker.js +4 -0
- package/dist/commands/dev/depBuildWorker/depBuilder.js +7 -0
- package/dist/commands/dev/depBuildWorker/dev-config.js +1 -0
- package/dist/commands/dev/depBuildWorker/getConfig.js +4 -0
- package/dist/commands/dev/depBuildWorker/workerPreset.js +4 -0
- package/dist/commands/dev/dev.js +14 -3
- package/dist/commands/dev/getBabelOpts.js +5 -0
- package/dist/commands/dev/getMarkupArgs.js +5 -0
- package/dist/commands/dev/printMemoryUsage.js +4 -0
- package/dist/commands/generators/jest.js +4 -1
- package/dist/commands/generators/prettier.js +2 -2
- package/dist/commands/generators/tailwindcss.js +2 -2
- package/dist/commands/lint.js +4 -0
- package/dist/{features/polyfill/swcPolyfill.d.ts → commands/mfsu/mfsu.d.ts} +0 -0
- package/dist/commands/mfsu/mfsu.js +97 -0
- package/dist/commands/mfsu/util.d.ts +28 -0
- package/dist/commands/mfsu/util.js +290 -0
- package/dist/commands/preview.js +4 -0
- package/dist/commands/verify-commit.js +5 -0
- package/dist/features/apiRoute/apiRoute.js +7 -0
- package/dist/features/apiRoute/dev-server/esbuild.js +4 -0
- package/dist/features/apiRoute/index.js +4 -0
- package/dist/features/apiRoute/vercel/esbuild.js +4 -0
- package/dist/features/appData/appData.js +10 -4
- package/dist/features/check/check.js +18 -1
- package/dist/features/clickToComponent/clickToComponent.js +4 -0
- package/dist/features/clientLoader/clientLoader.js +7 -0
- package/dist/features/codeSplitting/codeSplitting.js +18 -2
- package/dist/features/configPlugins/configPlugins.js +7 -0
- package/dist/features/depsOnDemand/depsOnDemand.d.ts +14 -0
- package/dist/features/depsOnDemand/depsOnDemand.js +54 -27
- package/dist/features/esmi/Service.js +27 -0
- package/dist/features/esmi/esmi.js +17 -3
- package/dist/features/exportStatic/exportStatic.js +12 -1
- package/dist/features/icons/esbuildIconPlugin.js +4 -0
- package/dist/features/icons/icons.js +39 -7
- package/dist/features/icons/loadIcon.d.ts +8 -0
- package/dist/features/icons/loadIcon.js +85 -0
- package/dist/features/icons/svgr.d.ts +5 -1
- package/dist/features/icons/svgr.js +14 -9
- package/dist/features/legacy/legacy.js +61 -10
- package/dist/features/lowImport/babelPlugin.js +4 -0
- package/dist/features/lowImport/lowImport.js +8 -0
- package/dist/features/mock/createMockMiddleware.js +4 -0
- package/dist/features/mock/getMockData.js +4 -0
- package/dist/features/mock/mock.js +4 -0
- package/dist/features/monorepo/redirect.js +68 -17
- package/dist/features/mpa/extractExports.js +10 -1
- package/dist/features/mpa/mpa.js +5 -0
- package/dist/features/overrides/overrides.js +3 -0
- package/dist/features/phantomDependency/phantomDependency.js +4 -0
- package/dist/features/polyfill/polyfill.js +8 -2
- package/dist/features/polyfill/publicPathPolyfill.js +4 -0
- package/dist/features/prepare/build.d.ts +2 -1
- package/dist/features/prepare/build.js +17 -2
- package/dist/features/prepare/esbuildPlugins/esbuildAliasPlugin.js +5 -0
- package/dist/features/prepare/esbuildPlugins/esbuildExternalPlugin.js +23 -37
- package/dist/features/prepare/prepare.js +4 -0
- package/dist/features/ssr/builder/builder.js +7 -0
- package/dist/features/ssr/builder/less-loader.js +4 -0
- package/dist/features/ssr/ssr.js +5 -0
- package/dist/features/ssr/webpack/webpack.js +4 -0
- package/dist/features/swc/swc.d.ts +3 -0
- package/dist/features/swc/swc.js +47 -0
- package/dist/features/terminal/terminal.js +1 -1
- package/dist/features/test/test.js +4 -0
- package/dist/features/tmpFiles/configTypes.js +4 -0
- package/dist/features/tmpFiles/routes.js +9 -3
- package/dist/features/tmpFiles/tmpFiles.js +35 -4
- package/dist/features/transform/babelPlugin.js +5 -0
- package/dist/features/transform/transform.js +4 -0
- package/dist/features/webpack/webpack.js +2 -0
- package/dist/index.js +9 -0
- package/dist/libs/folderCache/AutoUpdateSourceCodeCache.js +7 -0
- package/dist/libs/folderCache/LazySourceCodeCache.js +7 -0
- package/dist/libs/scan.js +23 -2
- package/dist/registerMethods.js +6 -0
- package/dist/types.d.ts +3 -0
- package/dist/utils/fileSizeReporter.js +4 -0
- package/dist/utils/transformIEAR.js +21 -0
- package/package.json +14 -14
- package/templates/history.tpl +3 -2
- package/templates/historyIntelli.tpl +127 -0
- package/templates/plugin.tpl +7 -5
- package/templates/route.tpl +2 -1
- package/dist/features/polyfill/swcPolyfill.js +0 -49
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -13,6 +13,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
16
20
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
17
21
|
mod
|
|
18
22
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -68,6 +72,7 @@ var DepBuilderInWorker = class {
|
|
|
68
72
|
});
|
|
69
73
|
});
|
|
70
74
|
}
|
|
75
|
+
// TODO: support watch and rebuild
|
|
71
76
|
async buildWithESBuild(opts) {
|
|
72
77
|
var _a;
|
|
73
78
|
const alias = { ...(_a = this.opts.depConfig.resolve) == null ? void 0 : _a.alias };
|
|
@@ -175,6 +180,8 @@ var DepBuilderInWorker = class {
|
|
|
175
180
|
depConfig.plugins = depConfig.plugins || [];
|
|
176
181
|
depConfig.plugins.push(new import_depChunkIdPrefixPlugin.DepChunkIdPrefixPlugin());
|
|
177
182
|
depConfig.plugins.push(
|
|
183
|
+
// FIXME remove ignore
|
|
184
|
+
// @ts-ignore
|
|
178
185
|
new import_stripSourceMapUrlPlugin.StripSourceMapUrlPlugin({
|
|
179
186
|
webpack: import_webpack.default
|
|
180
187
|
})
|
|
@@ -86,6 +86,7 @@ var dev_config_default = (api) => {
|
|
|
86
86
|
beforeBabelPresets,
|
|
87
87
|
extraBabelPlugins,
|
|
88
88
|
extraBabelPresets,
|
|
89
|
+
// vite 模式使用 ./plugins/ViteHtmlPlugin.ts 处理
|
|
89
90
|
mfsuWithESBuild: (_a = api.config.mfsu) == null ? void 0 : _a.esbuild,
|
|
90
91
|
mfsuStrategy: (_b = api.config.mfsu) == null ? void 0 : _b.strategy,
|
|
91
92
|
cache: {
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -33,6 +37,7 @@ var import_fs = require("fs");
|
|
|
33
37
|
var import_path = require("path");
|
|
34
38
|
var import_worker_threads = require("worker_threads");
|
|
35
39
|
var import_constants = require("../../constants");
|
|
40
|
+
var import_LazySourceCodeCache = require("../../libs/folderCache/LazySourceCodeCache");
|
|
36
41
|
var import_lazyImportFromCurrentPkg = require("../../utils/lazyImportFromCurrentPkg");
|
|
37
42
|
var import_createRouteMiddleware = require("./createRouteMiddleware");
|
|
38
43
|
var import_faviconMiddleware = require("./faviconMiddleware");
|
|
@@ -40,7 +45,6 @@ var import_getBabelOpts = require("./getBabelOpts");
|
|
|
40
45
|
var import_ViteHtmlPlugin = __toESM(require("./plugins/ViteHtmlPlugin"));
|
|
41
46
|
var import_printMemoryUsage = require("./printMemoryUsage");
|
|
42
47
|
var import_watch = require("./watch");
|
|
43
|
-
var import_LazySourceCodeCache = require("../../libs/folderCache/LazySourceCodeCache");
|
|
44
48
|
var bundlerWebpack = (0, import_lazyImportFromCurrentPkg.lazyImportFromCurrentPkg)("@umijs/bundler-webpack");
|
|
45
49
|
var bundlerVite = (0, import_lazyImportFromCurrentPkg.lazyImportFromCurrentPkg)("@umijs/bundler-vite");
|
|
46
50
|
var MFSU_EAGER_DEFAULT_INCLUDE = [
|
|
@@ -98,7 +102,8 @@ PORT=8888 umi dev
|
|
|
98
102
|
...(0, import_watch.expandJSPaths)((0, import_path.join)(absSrcPath, "loading")),
|
|
99
103
|
...(0, import_watch.expandJSPaths)((0, import_path.join)(absSrcPath, "app")),
|
|
100
104
|
...(0, import_watch.expandJSPaths)((0, import_path.join)(absSrcPath, "global")),
|
|
101
|
-
...(0, import_watch.expandCSSPaths)((0, import_path.join)(absSrcPath, "global"))
|
|
105
|
+
...(0, import_watch.expandCSSPaths)((0, import_path.join)(absSrcPath, "global")),
|
|
106
|
+
...(0, import_watch.expandCSSPaths)((0, import_path.join)(absSrcPath, "overrides"))
|
|
102
107
|
].filter(Boolean)
|
|
103
108
|
});
|
|
104
109
|
import_utils.lodash.uniq(watcherPaths.map(import_utils.winPath)).forEach((p) => {
|
|
@@ -207,7 +212,10 @@ PORT=8888 umi dev
|
|
|
207
212
|
if (isPublicAvailable) {
|
|
208
213
|
if (event === "unlinkDir" && path === publicDir) {
|
|
209
214
|
restartServer();
|
|
210
|
-
} else if (
|
|
215
|
+
} else if (
|
|
216
|
+
// listen public files all deleted
|
|
217
|
+
event === "unlink" && (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length === 0
|
|
218
|
+
) {
|
|
211
219
|
restartServer();
|
|
212
220
|
}
|
|
213
221
|
} else {
|
|
@@ -312,8 +320,11 @@ PORT=8888 umi dev
|
|
|
312
320
|
beforeMiddlewares: [].concat([
|
|
313
321
|
...beforeMiddlewares
|
|
314
322
|
]),
|
|
323
|
+
// vite 模式使用 ./plugins/ViteHtmlPlugin.ts 处理
|
|
315
324
|
afterMiddlewares: enableVite ? [middlewares.concat(import_faviconMiddleware.faviconMiddleware)] : middlewares.concat([
|
|
316
325
|
...api.config.mpa ? [] : [(0, import_createRouteMiddleware.createRouteMiddleware)({ api })],
|
|
326
|
+
// 放置 favicon 在 webpack middleware 之后,兼容 public 目录下有 favicon.ico 的场景
|
|
327
|
+
// ref: https://github.com/umijs/umi/issues/8024
|
|
317
328
|
import_faviconMiddleware.faviconMiddleware
|
|
318
329
|
]),
|
|
319
330
|
onDevCompileDone(opts2) {
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -37,6 +41,7 @@ async function getBabelOpts(opts) {
|
|
|
37
41
|
presetEnv: {},
|
|
38
42
|
presetReact: {
|
|
39
43
|
runtime: isGTEReact17 ? "automatic" : "classic",
|
|
44
|
+
// importSource cannot be set when runtime is classic
|
|
40
45
|
...isGTEReact17 ? {} : { importSource: void 0 }
|
|
41
46
|
},
|
|
42
47
|
presetTypeScript: {},
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -68,6 +72,7 @@ async function getMarkupArgs(opts) {
|
|
|
68
72
|
title: opts.api.config.title,
|
|
69
73
|
async modifyHTML(memo, args) {
|
|
70
74
|
let $ = import_cheerio.default.load(memo, {
|
|
75
|
+
// @ts-ignore
|
|
71
76
|
decodeEntities: false
|
|
72
77
|
});
|
|
73
78
|
$ = await opts.api.applyPlugins({
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -54,12 +54,15 @@ var jest_default = (api) => {
|
|
|
54
54
|
const basicDeps = {
|
|
55
55
|
jest: jestMajorVersion,
|
|
56
56
|
"@types/jest": jestMajorVersion,
|
|
57
|
+
// we use `jest.config.ts` so jest needs ts and ts-node
|
|
57
58
|
typescript: "^4",
|
|
58
59
|
"ts-node": "^10",
|
|
59
60
|
"cross-env": "^7"
|
|
60
61
|
};
|
|
61
62
|
const reactTestingDeps = {
|
|
63
|
+
// `jest-environment-jsdom` is no longer included in jest >= 28
|
|
62
64
|
"jest-environment-jsdom": jestMajorVersion,
|
|
65
|
+
// RTL
|
|
63
66
|
"@testing-library/jest-dom": "^5",
|
|
64
67
|
"@testing-library/react": "^13"
|
|
65
68
|
};
|
|
@@ -124,7 +127,7 @@ ${collectCoverageFrom.map((v) => ` '${v}'`).join(",\n")}
|
|
|
124
127
|
throw e;
|
|
125
128
|
}
|
|
126
129
|
};
|
|
127
|
-
`.
|
|
130
|
+
`.trimStart()
|
|
128
131
|
);
|
|
129
132
|
import_utils.logger.info("Write jest.config.ts");
|
|
130
133
|
h.installDeps();
|
|
@@ -58,7 +58,7 @@ var prettier_default = (api) => {
|
|
|
58
58
|
"overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }],
|
|
59
59
|
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"]
|
|
60
60
|
}
|
|
61
|
-
`.
|
|
61
|
+
`.trimStart()
|
|
62
62
|
);
|
|
63
63
|
import_utils.logger.info("Write .prettierrc");
|
|
64
64
|
(0, import_fs.writeFileSync)(
|
|
@@ -67,7 +67,7 @@ var prettier_default = (api) => {
|
|
|
67
67
|
node_modules
|
|
68
68
|
.umi
|
|
69
69
|
.umi-production
|
|
70
|
-
`.
|
|
70
|
+
`.trimStart()
|
|
71
71
|
);
|
|
72
72
|
import_utils.logger.info("Write .prettierignore");
|
|
73
73
|
h.installDeps();
|
|
@@ -56,8 +56,8 @@ var tailwindcss_default = (api) => {
|
|
|
56
56
|
module.exports = {
|
|
57
57
|
content: [
|
|
58
58
|
'./${srcPrefix}pages/**/*.tsx',
|
|
59
|
-
'./${srcPrefix}components
|
|
60
|
-
'./${srcPrefix}layouts
|
|
59
|
+
'./${srcPrefix}components/**/*.tsx',
|
|
60
|
+
'./${srcPrefix}layouts/**/*.tsx',
|
|
61
61
|
],
|
|
62
62
|
}
|
|
63
63
|
`.trimStart()
|
package/dist/commands/lint.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
File without changes
|
|
@@ -0,0 +1,97 @@
|
|
|
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/commands/mfsu/mfsu.ts
|
|
20
|
+
var mfsu_exports = {};
|
|
21
|
+
__export(mfsu_exports, {
|
|
22
|
+
default: () => mfsu_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(mfsu_exports);
|
|
25
|
+
var import_util = require("./util");
|
|
26
|
+
var HELP_TEXT = `
|
|
27
|
+
# MFSU CLI util
|
|
28
|
+
# umi mfsu [action]
|
|
29
|
+
|
|
30
|
+
# Show Help
|
|
31
|
+
$ umi mfsu
|
|
32
|
+
|
|
33
|
+
# Manually build mfsu dependencies
|
|
34
|
+
$ umi mfsu build
|
|
35
|
+
$ umi mfsu b
|
|
36
|
+
|
|
37
|
+
# list mfsu dependencies
|
|
38
|
+
$ umi mfsu list
|
|
39
|
+
$ umi mfsu ls
|
|
40
|
+
`.trim();
|
|
41
|
+
var mfsu_default = (api) => {
|
|
42
|
+
api.describe({
|
|
43
|
+
key: "mfsu-cli"
|
|
44
|
+
});
|
|
45
|
+
api.registerCommand({
|
|
46
|
+
name: "mfsu",
|
|
47
|
+
description: "umi mfsu CLI util",
|
|
48
|
+
details: HELP_TEXT,
|
|
49
|
+
configResolveMode: "strict",
|
|
50
|
+
async fn({ args }) {
|
|
51
|
+
var _a;
|
|
52
|
+
const { _ } = args;
|
|
53
|
+
const [command = "help"] = _;
|
|
54
|
+
if (api.config.mfsu === false) {
|
|
55
|
+
api.logger.info("MFSU is not enabled");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const util = ((_a = api.config.mfsu) == null ? void 0 : _a.strategy) === "eager" ? new import_util.EagerUtil(api) : new import_util.NormalUtil(api);
|
|
59
|
+
switch (command) {
|
|
60
|
+
case "build":
|
|
61
|
+
case "b":
|
|
62
|
+
try {
|
|
63
|
+
const { force } = args;
|
|
64
|
+
util.removeCacheJSON();
|
|
65
|
+
await util.build(force);
|
|
66
|
+
process.exit(0);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
process.exit(-1);
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case "list":
|
|
72
|
+
case "ls":
|
|
73
|
+
case "l":
|
|
74
|
+
util.listDeps();
|
|
75
|
+
break;
|
|
76
|
+
case "remove":
|
|
77
|
+
const { all } = args;
|
|
78
|
+
if (all) {
|
|
79
|
+
util.clearAllCache();
|
|
80
|
+
} else {
|
|
81
|
+
util.removeCacheJSON();
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "help":
|
|
85
|
+
printHelpInfo();
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
throw new Error(`Unsupported mfsu action`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
function printHelpInfo() {
|
|
94
|
+
console.log(HELP_TEXT);
|
|
95
|
+
}
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IApi } from '../../types';
|
|
2
|
+
export declare abstract class MFSUUtilBase {
|
|
3
|
+
readonly api: IApi;
|
|
4
|
+
protected mfsuCacheBase: string;
|
|
5
|
+
protected cliName: string;
|
|
6
|
+
constructor(api: IApi);
|
|
7
|
+
abstract jsonFilePath(): string;
|
|
8
|
+
abstract getCacheJSON(): string;
|
|
9
|
+
abstract listDeps(): void;
|
|
10
|
+
abstract build(force?: boolean): Promise<void>;
|
|
11
|
+
prepare(): Promise<any>;
|
|
12
|
+
removeCacheJSON(): void;
|
|
13
|
+
clearAllCache(): void;
|
|
14
|
+
printDeps(deps: any): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class EagerUtil extends MFSUUtilBase {
|
|
17
|
+
jsonFilePath(): string;
|
|
18
|
+
getCacheJSON(): any;
|
|
19
|
+
build(): Promise<void>;
|
|
20
|
+
listDeps(): void;
|
|
21
|
+
}
|
|
22
|
+
export declare class NormalUtil extends MFSUUtilBase {
|
|
23
|
+
jsonFilePath(): string;
|
|
24
|
+
getCacheJSON(): any;
|
|
25
|
+
listDeps(): void;
|
|
26
|
+
build(force: boolean): Promise<void>;
|
|
27
|
+
private normalBuild;
|
|
28
|
+
}
|