@umijs/preset-umi 4.0.41 → 4.0.43
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/build.d.ts +1 -1
- package/dist/commands/build.js +7 -2
- package/dist/commands/config/remove.js +4 -1
- package/dist/commands/config/set.js +4 -1
- package/dist/commands/dev/createRouteMiddleware.js +3 -1
- package/dist/commands/dev/depBuildWorker/depBuildWorker.js +10 -4
- package/dist/commands/dev/depBuildWorker/depBuilder.js +36 -26
- package/dist/commands/dev/depBuildWorker/getConfig.js +4 -1
- package/dist/commands/dev/depBuildWorker/workerPreset.js +4 -1
- package/dist/commands/dev/dev.d.ts +1 -1
- package/dist/commands/dev/dev.js +78 -30
- package/dist/commands/dev/getBabelOpts.js +4 -1
- package/dist/commands/dev/getMarkupArgs.js +4 -1
- package/dist/commands/dev/printMemoryUsage.js +7 -2
- package/dist/commands/generators/component.js +6 -1
- package/dist/commands/generators/cypress.js +5 -2
- package/dist/commands/generators/dva.js +5 -2
- package/dist/commands/generators/jest.js +9 -3
- package/dist/commands/generators/precommit.js +15 -6
- package/dist/commands/generators/prettier.js +10 -4
- package/dist/commands/generators/tailwindcss.js +10 -4
- package/dist/commands/generators/tsconfig.js +12 -4
- package/dist/commands/generators/utils.js +23 -7
- package/dist/commands/help.js +8 -2
- package/dist/commands/lint.js +8 -2
- package/dist/commands/plugin.js +6 -2
- package/dist/commands/preview.js +40 -19
- package/dist/commands/setup.d.ts +1 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/verify-commit.js +17 -5
- package/dist/features/apiRoute/apiRoute.js +53 -15
- package/dist/features/apiRoute/dev-server/esbuild.js +7 -2
- package/dist/features/apiRoute/index.js +4 -1
- package/dist/features/apiRoute/request.js +11 -3
- package/dist/features/apiRoute/vercel/esbuild.js +7 -2
- package/dist/features/appData/appData.d.ts +1 -1
- package/dist/features/appData/appData.js +27 -14
- package/dist/features/check/check.js +27 -8
- package/dist/features/clickToComponent/clickToComponent.js +4 -1
- package/dist/features/clientLoader/clientLoader.js +7 -2
- package/dist/features/codeSplitting/codeSplitting.js +22 -7
- package/dist/features/configPlugins/configPlugins.d.ts +1 -1
- package/dist/features/configPlugins/configPlugins.js +20 -7
- package/dist/features/configPlugins/schema.js +7 -1
- package/dist/features/crossorigin/crossorigin.js +6 -3
- package/dist/features/depsOnDemand/depsOnDemand.js +43 -7
- package/dist/features/devTool/devTool.js +3 -1
- package/dist/features/esmi/Service.js +21 -6
- package/dist/features/esmi/esbuildPlugins/requireToImport.js +40 -32
- package/dist/features/esmi/esbuildPlugins/topLevelExternal.js +13 -8
- package/dist/features/esmi/esmi.js +24 -12
- package/dist/features/exportStatic/exportStatic.js +53 -28
- package/dist/features/favicons/favicons.js +7 -2
- package/dist/features/icons/build.d.ts +13 -0
- package/dist/features/icons/build.js +80 -0
- package/dist/features/icons/esbuildPlugins/esbuildAliasPlugin.d.ts +4 -0
- package/dist/features/icons/esbuildPlugins/esbuildAliasPlugin.js +99 -0
- package/dist/features/icons/esbuildPlugins/esbuildCollectIconPlugin.d.ts +5 -0
- package/dist/features/icons/esbuildPlugins/esbuildCollectIconPlugin.js +57 -0
- package/dist/features/icons/esbuildPlugins/esbuildExternalPlugin.d.ts +2 -0
- package/dist/features/icons/esbuildPlugins/esbuildExternalPlugin.js +85 -0
- package/dist/features/icons/extract.d.ts +1 -0
- package/dist/features/icons/extract.js +96 -0
- package/dist/features/icons/icons.d.ts +3 -0
- package/dist/features/icons/icons.js +238 -0
- package/dist/features/icons/svgr.d.ts +11 -0
- package/dist/features/icons/svgr.js +83 -0
- package/dist/features/legacy/legacy.js +37 -14
- package/dist/features/lowImport/babelPlugin.js +65 -12
- package/dist/features/lowImport/lowImport.js +10 -3
- package/dist/features/mock/createMockMiddleware.js +4 -1
- package/dist/features/mock/getMockData.js +28 -10
- package/dist/features/mock/mock.js +7 -2
- package/dist/features/monorepo/redirect.d.ts +0 -4
- package/dist/features/monorepo/redirect.js +31 -33
- package/dist/features/mpa/extractExports.js +4 -1
- package/dist/features/mpa/mpa.js +44 -27
- package/dist/features/overrides/overrides.js +15 -13
- package/dist/features/phantomDependency/phantomDependency.d.ts +3 -0
- package/dist/features/phantomDependency/phantomDependency.js +106 -0
- package/dist/features/polyfill/polyfill.js +32 -22
- package/dist/features/polyfill/publicPathPolyfill.js +4 -1
- package/dist/features/polyfill/swcPolyfill.js +7 -2
- package/dist/features/routePrefetch/routePrefetch.js +22 -5
- package/dist/features/ssr/builder/assets-loader.js +19 -13
- package/dist/features/ssr/builder/builder.js +17 -2
- package/dist/features/ssr/builder/css-loader.js +4 -1
- package/dist/features/ssr/builder/less-loader.js +22 -8
- package/dist/features/ssr/ssr.js +23 -7
- package/dist/features/ssr/utils.js +10 -4
- package/dist/features/ssr/webpack/webpack.js +4 -1
- package/dist/features/terminal/terminal.js +1 -1
- package/dist/features/test/test.js +37 -24
- package/dist/features/tmpFiles/configTypes.js +4 -1
- package/dist/features/tmpFiles/routes.js +27 -10
- package/dist/features/tmpFiles/tmpFiles.js +138 -89
- package/dist/features/transform/babelPlugin.js +7 -2
- package/dist/features/transform/transform.js +12 -6
- package/dist/features/vite/vite.js +5 -1
- package/dist/features/webpack/webpack.js +30 -27
- package/dist/index.js +6 -1
- package/dist/libs/folderCache/AutoUpdateFolderCache.js +6 -1
- package/dist/libs/folderCache/AutoUpdateSourceCodeCache.js +18 -6
- package/dist/libs/folderCache/LazySourceCodeCache.d.ts +1 -0
- package/dist/libs/folderCache/LazySourceCodeCache.js +21 -6
- package/dist/libs/scan.js +17 -6
- package/dist/registerMethods.js +21 -5
- package/dist/types.d.ts +17 -4
- package/dist/utils/fileSizeReporter.js +29 -11
- package/dist/utils/transformIEAR.js +37 -31
- package/package.json +18 -16
- package/templates/TestBrowser.tpl +0 -1
package/dist/commands/build.d.ts
CHANGED
package/dist/commands/build.js
CHANGED
|
@@ -131,7 +131,10 @@ umi build --clean
|
|
|
131
131
|
if (api.config.vite) {
|
|
132
132
|
stats = await bundlerVite.build(opts);
|
|
133
133
|
} else {
|
|
134
|
-
const absOutputPath = (0, import_path.resolve)(
|
|
134
|
+
const absOutputPath = (0, import_path.resolve)(
|
|
135
|
+
opts.cwd,
|
|
136
|
+
opts.config.outputPath || bundlerWebpack.DEFAULT_OUTPUT_PATH
|
|
137
|
+
);
|
|
135
138
|
const previousFileSizes = (0, import_fileSizeReporter.measureFileSizesBeforeBuild)(absOutputPath);
|
|
136
139
|
stats = await bundlerWebpack.build(opts);
|
|
137
140
|
console.log();
|
|
@@ -152,7 +155,9 @@ umi build --clean
|
|
|
152
155
|
const markupArgs = await (0, import_getMarkupArgs.getMarkupArgs)({ api });
|
|
153
156
|
const finalMarkUpArgs = {
|
|
154
157
|
...markupArgs,
|
|
155
|
-
styles: markupArgs.styles.concat(
|
|
158
|
+
styles: markupArgs.styles.concat(
|
|
159
|
+
api.config.vite ? [] : [...(assetsMap["umi.css"] || []).map((src) => ({ src }))]
|
|
160
|
+
),
|
|
156
161
|
scripts: (api.config.vite ? [] : [...(assetsMap["umi.js"] || []).map((src) => ({ src }))]).concat(markupArgs.scripts),
|
|
157
162
|
esmScript: !!opts.config.esm || vite,
|
|
158
163
|
path: "/"
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/config/remove.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/config/set.ts
|
|
@@ -53,7 +53,9 @@ function createRouteMiddleware(opts) {
|
|
|
53
53
|
});
|
|
54
54
|
const requestHandler = await (0, import_server.createRequestHandler)({
|
|
55
55
|
...markupArgs,
|
|
56
|
-
styles: markupArgs.styles.concat(
|
|
56
|
+
styles: markupArgs.styles.concat(
|
|
57
|
+
(assetsMap["umi.css"] || []).map((src) => ({ src }))
|
|
58
|
+
),
|
|
57
59
|
scripts: (assetsMap["umi.js"] || []).map((src) => ({ src })).concat(markupArgs.scripts),
|
|
58
60
|
esmScript: false,
|
|
59
61
|
historyType: ((_a = opts.api.config.history) == null ? void 0 : _a.type) || "browser"
|
|
@@ -12,7 +12,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
}
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
17
|
+
mod
|
|
18
|
+
));
|
|
16
19
|
|
|
17
20
|
// src/commands/dev/depBuildWorker/depBuildWorker.ts
|
|
18
21
|
var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
@@ -37,8 +40,8 @@ async function start() {
|
|
|
37
40
|
function build(deps) {
|
|
38
41
|
import_utils.logger.info("[MFSU][eager] build worker start to build");
|
|
39
42
|
return builder.build({ deps }).catch((e) => {
|
|
40
|
-
import_utils.logger.
|
|
41
|
-
import_worker_threads.parentPort.postMessage({
|
|
43
|
+
import_utils.logger.debug("[MFSU][eager][worker] build worker failed", e);
|
|
44
|
+
import_worker_threads.parentPort.postMessage({ done: { withError: e } });
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
function scheduleBuild() {
|
|
@@ -57,7 +60,10 @@ async function start() {
|
|
|
57
60
|
});
|
|
58
61
|
const start2 = Date.now();
|
|
59
62
|
const opts = await (0, import_getConfig.getDevConfig)();
|
|
60
|
-
const cacheDirectoryPath = (0, import_path.resolve)(
|
|
63
|
+
const cacheDirectoryPath = (0, import_path.resolve)(
|
|
64
|
+
opts.rootDir || opts.cwd,
|
|
65
|
+
opts.config.cacheDirectoryPath || "node_modules/.cache"
|
|
66
|
+
);
|
|
61
67
|
const depConfig = await (0, import_bundler_webpack.getConfig)({
|
|
62
68
|
cwd: opts.cwd,
|
|
63
69
|
rootDir: opts.rootDir,
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/depBuildWorker/depBuilder.ts
|
|
@@ -48,7 +51,6 @@ var DepBuilderInWorker = class {
|
|
|
48
51
|
return new Promise((resolve, reject) => {
|
|
49
52
|
const compiler = (0, import_webpack.default)(config);
|
|
50
53
|
compiler.run((err, stats) => {
|
|
51
|
-
opts.onBuildComplete();
|
|
52
54
|
if (err || (stats == null ? void 0 : stats.hasErrors())) {
|
|
53
55
|
if (err) {
|
|
54
56
|
reject(err);
|
|
@@ -58,6 +60,7 @@ var DepBuilderInWorker = class {
|
|
|
58
60
|
reject(new Error(errorMsg));
|
|
59
61
|
}
|
|
60
62
|
} else {
|
|
63
|
+
opts.onBuildComplete();
|
|
61
64
|
resolve(stats);
|
|
62
65
|
}
|
|
63
66
|
compiler.close(() => {
|
|
@@ -91,15 +94,19 @@ var DepBuilderInWorker = class {
|
|
|
91
94
|
},
|
|
92
95
|
inlineStyle: true
|
|
93
96
|
});
|
|
94
|
-
import_utils.logger.event(
|
|
97
|
+
import_utils.logger.event(
|
|
98
|
+
`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`
|
|
99
|
+
);
|
|
95
100
|
opts.onBuildComplete();
|
|
96
101
|
}
|
|
97
102
|
async build(opts) {
|
|
98
103
|
this.isBuilding = true;
|
|
99
|
-
const onBuildComplete = () => {
|
|
104
|
+
const onBuildComplete = (e = null) => {
|
|
100
105
|
this.isBuilding = false;
|
|
101
106
|
import_worker_threads.parentPort.postMessage({
|
|
102
|
-
done:
|
|
107
|
+
done: {
|
|
108
|
+
withError: e
|
|
109
|
+
}
|
|
103
110
|
});
|
|
104
111
|
};
|
|
105
112
|
try {
|
|
@@ -114,10 +121,7 @@ var DepBuilderInWorker = class {
|
|
|
114
121
|
await this.buildWithWebpack(newOpts);
|
|
115
122
|
}
|
|
116
123
|
} catch (e) {
|
|
117
|
-
|
|
118
|
-
error: e
|
|
119
|
-
});
|
|
120
|
-
onBuildComplete();
|
|
124
|
+
onBuildComplete(e);
|
|
121
125
|
throw e;
|
|
122
126
|
}
|
|
123
127
|
}
|
|
@@ -135,7 +139,7 @@ var DepBuilderInWorker = class {
|
|
|
135
139
|
const content = await dep.buildExposeContent();
|
|
136
140
|
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, dep.filePath), content, "utf-8");
|
|
137
141
|
}
|
|
138
|
-
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, MF_ENTRY), '"
|
|
142
|
+
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, MF_ENTRY), '"😛"', "utf-8");
|
|
139
143
|
}
|
|
140
144
|
getWebpackConfig(opts) {
|
|
141
145
|
var _a, _b;
|
|
@@ -170,26 +174,32 @@ var DepBuilderInWorker = class {
|
|
|
170
174
|
};
|
|
171
175
|
depConfig.plugins = depConfig.plugins || [];
|
|
172
176
|
depConfig.plugins.push(new import_depChunkIdPrefixPlugin.DepChunkIdPrefixPlugin());
|
|
173
|
-
depConfig.plugins.push(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
depConfig.plugins.push(
|
|
178
|
+
new import_stripSourceMapUrlPlugin.StripSourceMapUrlPlugin({
|
|
179
|
+
webpack: import_webpack.default
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
depConfig.plugins.push(
|
|
183
|
+
new import_webpack.default.ProgressPlugin((percent, msg) => {
|
|
184
|
+
import_worker_threads.parentPort.postMessage({ progress: { percent, status: msg } });
|
|
185
|
+
})
|
|
186
|
+
);
|
|
179
187
|
const exposes = opts.deps.reduce((memo, dep) => {
|
|
180
188
|
memo[`./${dep.file}`] = (0, import_path.join)(this.opts.tmpBase, dep.filePath);
|
|
181
189
|
return memo;
|
|
182
190
|
}, {});
|
|
183
|
-
depConfig.plugins.push(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
depConfig.plugins.push(
|
|
192
|
+
new import_webpack.default.container.ModuleFederationPlugin({
|
|
193
|
+
library: {
|
|
194
|
+
type: "global",
|
|
195
|
+
name: mfName
|
|
196
|
+
},
|
|
197
|
+
name: mfName,
|
|
198
|
+
filename: import_mfsu.REMOTE_FILE_FULL,
|
|
199
|
+
exposes,
|
|
200
|
+
shared: this.opts.shared || {}
|
|
201
|
+
})
|
|
202
|
+
);
|
|
193
203
|
return depConfig;
|
|
194
204
|
}
|
|
195
205
|
};
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/depBuildWorker/getConfig.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/depBuildWorker/workerPreset.ts
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/dev.ts
|
|
@@ -73,7 +76,7 @@ PORT=8888 umi dev
|
|
|
73
76
|
current: api.appData.pkg
|
|
74
77
|
}
|
|
75
78
|
});
|
|
76
|
-
async
|
|
79
|
+
const generate = async (opts2) => {
|
|
77
80
|
await api.applyPlugins({
|
|
78
81
|
key: "onGenerateFiles",
|
|
79
82
|
args: {
|
|
@@ -81,7 +84,7 @@ PORT=8888 umi dev
|
|
|
81
84
|
isFirstTime: opts2.isFirstTime
|
|
82
85
|
}
|
|
83
86
|
});
|
|
84
|
-
}
|
|
87
|
+
};
|
|
85
88
|
await generate({
|
|
86
89
|
isFirstTime: true
|
|
87
90
|
});
|
|
@@ -137,33 +140,41 @@ PORT=8888 umi dev
|
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
});
|
|
140
|
-
(0, import_watch.addUnWatch)(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
(0, import_watch.addUnWatch)(
|
|
144
|
+
api.service.configManager.watch({
|
|
145
|
+
schemas: api.service.configSchemas,
|
|
146
|
+
onChangeTypes: api.service.configOnChanges,
|
|
147
|
+
async onChange(opts2) {
|
|
148
|
+
await api.applyPlugins({
|
|
149
|
+
key: "onCheckConfig",
|
|
150
|
+
args: {
|
|
151
|
+
config: api.config,
|
|
152
|
+
userConfig: api.userConfig
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const { data } = opts2;
|
|
156
|
+
if (data.changes[api.ConfigChangeType.reload]) {
|
|
157
|
+
import_utils.logger.event(
|
|
158
|
+
`config ${data.changes[api.ConfigChangeType.reload].join(
|
|
159
|
+
", "
|
|
160
|
+
)} changed, restart server...`
|
|
161
|
+
);
|
|
162
|
+
api.restartServer();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
await api.service.resolveConfig();
|
|
166
|
+
if (data.changes[api.ConfigChangeType.regenerateTmpFiles]) {
|
|
167
|
+
import_utils.logger.event(
|
|
168
|
+
`config ${data.changes[api.ConfigChangeType.regenerateTmpFiles].join(", ")} changed, regenerate tmp files...`
|
|
169
|
+
);
|
|
170
|
+
await generate({ isFirstTime: false });
|
|
171
|
+
}
|
|
172
|
+
for await (const fn of data.fns) {
|
|
173
|
+
await fn({ generate });
|
|
149
174
|
}
|
|
150
|
-
});
|
|
151
|
-
const { data } = opts2;
|
|
152
|
-
if (data.changes[api.ConfigChangeType.reload]) {
|
|
153
|
-
import_utils.logger.event(`config ${data.changes[api.ConfigChangeType.reload].join(", ")} changed, restart server...`);
|
|
154
|
-
api.restartServer();
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
await api.service.resolveConfig();
|
|
158
|
-
if (data.changes[api.ConfigChangeType.regenerateTmpFiles]) {
|
|
159
|
-
import_utils.logger.event(`config ${data.changes[api.ConfigChangeType.regenerateTmpFiles].join(", ")} changed, regenerate tmp files...`);
|
|
160
|
-
await generate({ isFirstTime: false });
|
|
161
|
-
}
|
|
162
|
-
for (const fn of data.fns) {
|
|
163
|
-
fn();
|
|
164
175
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
176
|
+
})
|
|
177
|
+
);
|
|
167
178
|
const pluginFiles = [
|
|
168
179
|
(0, import_path.join)(api.cwd, "plugin.ts"),
|
|
169
180
|
(0, import_path.join)(api.cwd, "plugin.js")
|
|
@@ -178,6 +189,36 @@ PORT=8888 umi dev
|
|
|
178
189
|
}
|
|
179
190
|
});
|
|
180
191
|
});
|
|
192
|
+
function watchPublicDirChange() {
|
|
193
|
+
const publicDir = (0, import_path.join)(api.cwd, "public");
|
|
194
|
+
const isPublicAvailable = (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length;
|
|
195
|
+
let restarted = false;
|
|
196
|
+
const restartServer = () => {
|
|
197
|
+
if (restarted)
|
|
198
|
+
return;
|
|
199
|
+
restarted = true;
|
|
200
|
+
import_utils.logger.event(`public dir changed, restart server...`);
|
|
201
|
+
api.restartServer();
|
|
202
|
+
};
|
|
203
|
+
(0, import_watch.watch)({
|
|
204
|
+
path: publicDir,
|
|
205
|
+
addToUnWatches: true,
|
|
206
|
+
onChange(event, path) {
|
|
207
|
+
if (isPublicAvailable) {
|
|
208
|
+
if (event === "unlinkDir" && path === publicDir) {
|
|
209
|
+
restartServer();
|
|
210
|
+
} else if (event === "unlink" && (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length === 0) {
|
|
211
|
+
restartServer();
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
if (event === "add" && (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length === 1) {
|
|
215
|
+
restartServer();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
watchPublicDirChange();
|
|
181
222
|
const beforeMiddlewares = await api.applyPlugins({
|
|
182
223
|
key: "addBeforeMiddlewares",
|
|
183
224
|
initialValue: []
|
|
@@ -222,7 +263,12 @@ PORT=8888 umi dev
|
|
|
222
263
|
if (((_b = api.config.mfsu) == null ? void 0 : _b.strategy) === "eager") {
|
|
223
264
|
srcCodeCache = new import_LazySourceCodeCache.LazySourceCodeCache({
|
|
224
265
|
cwd: api.paths.absSrcPath,
|
|
225
|
-
cachePath: (0, import_path.join)(
|
|
266
|
+
cachePath: (0, import_path.join)(
|
|
267
|
+
api.paths.absNodeModulesPath,
|
|
268
|
+
".cache",
|
|
269
|
+
"mfsu",
|
|
270
|
+
"mfsu_v4"
|
|
271
|
+
)
|
|
226
272
|
});
|
|
227
273
|
await srcCodeCache.init();
|
|
228
274
|
(0, import_watch.addUnWatch)(() => {
|
|
@@ -230,7 +276,9 @@ PORT=8888 umi dev
|
|
|
230
276
|
});
|
|
231
277
|
let currentWorker = null;
|
|
232
278
|
const initWorker = () => {
|
|
233
|
-
currentWorker = new import_worker_threads.Worker(
|
|
279
|
+
currentWorker = new import_worker_threads.Worker(
|
|
280
|
+
(0, import_path.join)(__dirname, "depBuildWorker/depBuildWorker.js")
|
|
281
|
+
);
|
|
234
282
|
currentWorker.on("exit", () => {
|
|
235
283
|
initWorker();
|
|
236
284
|
});
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/getBabelOpts.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/getMarkupArgs.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/commands/dev/printMemoryUsage.ts
|
|
@@ -30,7 +33,9 @@ var import_process = __toESM(require("process"));
|
|
|
30
33
|
function printMemoryUsage() {
|
|
31
34
|
const used = import_process.default.memoryUsage().heapUsed / 1024 / 1024;
|
|
32
35
|
const rss = import_process.default.memoryUsage().rss / 1024 / 1024;
|
|
33
|
-
import_utils.logger.info(
|
|
36
|
+
import_utils.logger.info(
|
|
37
|
+
`Memory Usage: ${Math.round(used * 100) / 100} MB (RSS: ${Math.round(rss * 100) / 100} MB)`
|
|
38
|
+
);
|
|
34
39
|
}
|
|
35
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
41
|
0 && (module.exports = {
|
|
@@ -77,7 +77,12 @@ var ComponentGenerator = class {
|
|
|
77
77
|
async run() {
|
|
78
78
|
const { appRoot, args } = this.opts;
|
|
79
79
|
const capitalizeName = import_utils.lodash.upperFirst(this.name);
|
|
80
|
-
const base = (0, import_path.join)(
|
|
80
|
+
const base = (0, import_path.join)(
|
|
81
|
+
this.opts.srcPath,
|
|
82
|
+
"components",
|
|
83
|
+
this.dir,
|
|
84
|
+
capitalizeName
|
|
85
|
+
);
|
|
81
86
|
const { _, eject: _eject, fallback, ...restArgs } = args;
|
|
82
87
|
const indexFile = (0, import_path.join)(base, "index.ts");
|
|
83
88
|
const compFile = (0, import_path.join)(base, `${capitalizeName}.tsx`);
|
|
@@ -53,7 +53,9 @@ var cypress_default = (api) => {
|
|
|
53
53
|
"e2e:ci": "start-server-and-test preview http://127.0.0.1:9572 e2e"
|
|
54
54
|
});
|
|
55
55
|
h.appendGitIgnore(["/cypress/screenshots", "/cypress/videos"]);
|
|
56
|
-
(0, import_fs.writeFileSync)(
|
|
56
|
+
(0, import_fs.writeFileSync)(
|
|
57
|
+
(0, import_path.join)(api.cwd, "cypress.config.ts"),
|
|
58
|
+
`
|
|
57
59
|
import { defineConfig } from "cypress";
|
|
58
60
|
|
|
59
61
|
const PORT = process.env.PORT || "8000";
|
|
@@ -66,7 +68,8 @@ export default defineConfig({
|
|
|
66
68
|
baseUrl: \`http://localhost:\${PORT}\`,
|
|
67
69
|
},
|
|
68
70
|
});
|
|
69
|
-
`.trim()
|
|
71
|
+
`.trim()
|
|
72
|
+
);
|
|
70
73
|
import_utils.logger.info("Write cypress.config.ts");
|
|
71
74
|
await (0, import_utils.generateFile)({
|
|
72
75
|
target: (0, import_path.join)(api.paths.cwd, "cypress"),
|
|
@@ -48,7 +48,9 @@ var dva_default = (api) => {
|
|
|
48
48
|
h.appendInternalPlugin("@umijs/plugins/dist/dva");
|
|
49
49
|
import_utils.logger.info("Update config file");
|
|
50
50
|
const modelsPath = (0, import_path.join)(api.paths.absSrcPath, "models");
|
|
51
|
-
import_utils.fsExtra.outputFileSync(
|
|
51
|
+
import_utils.fsExtra.outputFileSync(
|
|
52
|
+
(0, import_path.join)(modelsPath, "count.ts"),
|
|
53
|
+
`
|
|
52
54
|
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
|
53
55
|
|
|
54
56
|
export default {
|
|
@@ -68,7 +70,8 @@ export default {
|
|
|
68
70
|
},
|
|
69
71
|
},
|
|
70
72
|
};
|
|
71
|
-
`
|
|
73
|
+
`
|
|
74
|
+
);
|
|
72
75
|
import_utils.logger.info("Write example model");
|
|
73
76
|
h.installDeps();
|
|
74
77
|
}
|
|
@@ -64,7 +64,10 @@ var jest_default = (api) => {
|
|
|
64
64
|
"@types/testing-library__jest-dom": "^5.14.5"
|
|
65
65
|
} : basicDeps;
|
|
66
66
|
h.addDevDeps(packageToInstall);
|
|
67
|
-
h.addScript(
|
|
67
|
+
h.addScript(
|
|
68
|
+
"test",
|
|
69
|
+
"cross-env TS_NODE_TRANSPILE_ONLY=yes jest --passWithNoTests"
|
|
70
|
+
);
|
|
68
71
|
const setupImports = res.willUseTLR ? [
|
|
69
72
|
`import '@testing-library/jest-dom';`,
|
|
70
73
|
`import '${api.appData.umi.importSource}/test-setup'`
|
|
@@ -89,7 +92,9 @@ var jest_default = (api) => {
|
|
|
89
92
|
"!config/**",
|
|
90
93
|
"!mock/**"
|
|
91
94
|
];
|
|
92
|
-
(0, import_fs.writeFileSync)(
|
|
95
|
+
(0, import_fs.writeFileSync)(
|
|
96
|
+
(0, import_path.join)(api.cwd, "jest.config.ts"),
|
|
97
|
+
`
|
|
93
98
|
import { Config, configUmiAlias, createConfig } from '${importSource}/test';
|
|
94
99
|
|
|
95
100
|
export default async () => {
|
|
@@ -114,7 +119,8 @@ export default async () => {
|
|
|
114
119
|
throw e;
|
|
115
120
|
}
|
|
116
121
|
};
|
|
117
|
-
`.trimLeft()
|
|
122
|
+
`.trimLeft()
|
|
123
|
+
);
|
|
118
124
|
import_utils.logger.info("Write jest.config.ts");
|
|
119
125
|
h.installDeps();
|
|
120
126
|
}
|
|
@@ -47,7 +47,9 @@ var precommit_default = (api) => {
|
|
|
47
47
|
});
|
|
48
48
|
h.addScript("prepare", "husky install");
|
|
49
49
|
if (!(0, import_fs.existsSync)((0, import_path.join)(api.cwd, ".lintstagedrc")) && !api.pkg["lint-staged"]) {
|
|
50
|
-
(0, import_fs.writeFileSync)(
|
|
50
|
+
(0, import_fs.writeFileSync)(
|
|
51
|
+
(0, import_path.join)(api.cwd, ".lintstagedrc"),
|
|
52
|
+
`
|
|
51
53
|
{
|
|
52
54
|
"*.{md,json}": [
|
|
53
55
|
"prettier --cache --write"
|
|
@@ -65,7 +67,8 @@ var precommit_default = (api) => {
|
|
|
65
67
|
"prettier --cache --parser=typescript --write"
|
|
66
68
|
]
|
|
67
69
|
}
|
|
68
|
-
`.trimStart()
|
|
70
|
+
`.trimStart()
|
|
71
|
+
);
|
|
69
72
|
import_utils.logger.info("Write .lintstagedrc");
|
|
70
73
|
}
|
|
71
74
|
if (!(0, import_fs.existsSync)((0, import_path.join)(api.cwd, ".husky"))) {
|
|
@@ -73,24 +76,30 @@ var precommit_default = (api) => {
|
|
|
73
76
|
import_utils.logger.info("Create .husky");
|
|
74
77
|
}
|
|
75
78
|
if (!(0, import_fs.existsSync)((0, import_path.join)(api.cwd, ".husky/commit-msg"))) {
|
|
76
|
-
(0, import_fs.writeFileSync)(
|
|
79
|
+
(0, import_fs.writeFileSync)(
|
|
80
|
+
(0, import_path.join)(api.cwd, ".husky/commit-msg"),
|
|
81
|
+
`
|
|
77
82
|
#!/usr/bin/env sh
|
|
78
83
|
. "$(dirname -- "$0")/_/husky.sh"
|
|
79
84
|
|
|
80
85
|
npx --no-install ${cliName} verify-commit $1
|
|
81
|
-
`.trimStart()
|
|
86
|
+
`.trimStart()
|
|
87
|
+
);
|
|
82
88
|
import_utils.logger.info("Write commit-msg");
|
|
83
89
|
if (process.platform !== "win32") {
|
|
84
90
|
import_utils.execa.execaCommandSync("chmod +x .husky/commit-msg");
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
if (!(0, import_fs.existsSync)((0, import_path.join)(api.cwd, ".husky/pre-commit"))) {
|
|
88
|
-
(0, import_fs.writeFileSync)(
|
|
94
|
+
(0, import_fs.writeFileSync)(
|
|
95
|
+
(0, import_path.join)(api.cwd, ".husky/pre-commit"),
|
|
96
|
+
`
|
|
89
97
|
#!/usr/bin/env sh
|
|
90
98
|
. "$(dirname -- "$0")/_/husky.sh"
|
|
91
99
|
|
|
92
100
|
npx --no-install lint-staged --quiet
|
|
93
|
-
`.trimStart()
|
|
101
|
+
`.trimStart()
|
|
102
|
+
);
|
|
94
103
|
import_utils.logger.info("Write pre-commit");
|
|
95
104
|
if (process.platform !== "win32") {
|
|
96
105
|
import_utils.execa.execaCommandSync("chmod +x .husky/pre-commit");
|
|
@@ -47,7 +47,9 @@ var prettier_default = (api) => {
|
|
|
47
47
|
"prettier-plugin-organize-imports": "^2",
|
|
48
48
|
"prettier-plugin-packagejson": "^2"
|
|
49
49
|
});
|
|
50
|
-
(0, import_fs.writeFileSync)(
|
|
50
|
+
(0, import_fs.writeFileSync)(
|
|
51
|
+
(0, import_path.join)(api.cwd, ".prettierrc"),
|
|
52
|
+
`
|
|
51
53
|
{
|
|
52
54
|
"printWidth": 80,
|
|
53
55
|
"singleQuote": true,
|
|
@@ -56,13 +58,17 @@ var prettier_default = (api) => {
|
|
|
56
58
|
"overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }],
|
|
57
59
|
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"]
|
|
58
60
|
}
|
|
59
|
-
`.trimLeft()
|
|
61
|
+
`.trimLeft()
|
|
62
|
+
);
|
|
60
63
|
import_utils.logger.info("Write .prettierrc");
|
|
61
|
-
(0, import_fs.writeFileSync)(
|
|
64
|
+
(0, import_fs.writeFileSync)(
|
|
65
|
+
(0, import_path.join)(api.cwd, ".prettierignore"),
|
|
66
|
+
`
|
|
62
67
|
node_modules
|
|
63
68
|
.umi
|
|
64
69
|
.umi-production
|
|
65
|
-
`.trimLeft()
|
|
70
|
+
`.trimLeft()
|
|
71
|
+
);
|
|
66
72
|
import_utils.logger.info("Write .prettierignore");
|
|
67
73
|
h.installDeps();
|
|
68
74
|
}
|