@umijs/core 4.0.47 → 4.0.49
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/service/service.d.ts +1 -1
- package/dist/service/service.js +40 -6
- package/package.json +3 -3
package/dist/service/service.js
CHANGED
|
@@ -301,7 +301,7 @@ var Service = class {
|
|
|
301
301
|
});
|
|
302
302
|
this.stage = import_types.ServiceStage.runCommand;
|
|
303
303
|
let ret = await command.fn({ args });
|
|
304
|
-
this.
|
|
304
|
+
this._profilePlugins();
|
|
305
305
|
return ret;
|
|
306
306
|
}
|
|
307
307
|
async getPaths() {
|
|
@@ -334,13 +334,47 @@ var Service = class {
|
|
|
334
334
|
this.config = import_utils.lodash.merge(defaultConfig, config);
|
|
335
335
|
return { config, defaultConfig };
|
|
336
336
|
}
|
|
337
|
-
|
|
338
|
-
if (this.args.
|
|
337
|
+
_profilePlugins() {
|
|
338
|
+
if (this.args.profilePlugins) {
|
|
339
339
|
console.log();
|
|
340
|
-
|
|
340
|
+
Object.keys(this.plugins).map((id) => {
|
|
341
341
|
const plugin = this.plugins[id];
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
const total = totalTime(plugin);
|
|
343
|
+
return {
|
|
344
|
+
id,
|
|
345
|
+
total,
|
|
346
|
+
register: plugin.time.register || 0,
|
|
347
|
+
hooks: plugin.time.hooks
|
|
348
|
+
};
|
|
349
|
+
}).filter((time) => {
|
|
350
|
+
return time.total > (this.args.profilePluginsLimit ?? 10);
|
|
351
|
+
}).sort((a, b) => b.total > a.total ? 1 : -1).forEach((time) => {
|
|
352
|
+
console.log(import_utils.chalk.green("plugin"), time.id, time.total);
|
|
353
|
+
if (this.args.profilePluginsVerbose) {
|
|
354
|
+
console.log(" ", import_utils.chalk.green("register"), time.register);
|
|
355
|
+
console.log(
|
|
356
|
+
" ",
|
|
357
|
+
import_utils.chalk.green("hooks"),
|
|
358
|
+
JSON.stringify(sortHooks(time.hooks))
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function sortHooks(hooks) {
|
|
364
|
+
const ret = {};
|
|
365
|
+
Object.keys(hooks).sort((a, b) => {
|
|
366
|
+
return add(hooks[b]) - add(hooks[a]);
|
|
367
|
+
}).forEach((key) => {
|
|
368
|
+
ret[key] = hooks[key];
|
|
369
|
+
});
|
|
370
|
+
return ret;
|
|
371
|
+
}
|
|
372
|
+
function totalTime(plugin) {
|
|
373
|
+
const time = plugin.time;
|
|
374
|
+
return (time.register || 0) + Object.values(time.hooks).reduce((a, b) => a + add(b), 0);
|
|
375
|
+
}
|
|
376
|
+
function add(nums) {
|
|
377
|
+
return nums.reduce((a, b) => a + b, 0);
|
|
344
378
|
}
|
|
345
379
|
}
|
|
346
380
|
async initPreset(opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.49",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
6
|
"repository": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "umi-scripts jest-turbo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-utils": "4.0.
|
|
25
|
-
"@umijs/utils": "4.0.
|
|
24
|
+
"@umijs/bundler-utils": "4.0.49",
|
|
25
|
+
"@umijs/utils": "4.0.49"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"dotenv": "16.0.0",
|