feat: 优化fes命令的速度

编写命令时,比较大的库需要使用require的方式按需加载
This commit is contained in:
万纯 2021-02-03 10:13:43 +08:00
parent 25efdcd1fc
commit f8c03ff00f
3 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import { runCLI } from 'jest';
import assert from 'assert'; import assert from 'assert';
import { join } from 'path'; import { join } from 'path';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
@ -71,6 +71,8 @@ export default function (api) {
}, {}); }, {});
args.debug && logger.log(`config from args: ${JSON.stringify(argsConfig)}`); args.debug && logger.log(`config from args: ${JSON.stringify(argsConfig)}`);
// 比较大的库建议使用require使用时才加载提升fes命令的效率
const { runCLI } = require('jest');
// Run jest // Run jest
const result = await runCLI( const result = await runCLI(
{ {

View File

@ -1,6 +1,5 @@
import { Server } from '@umijs/server';
import { delay } from '@umijs/utils';
import assert from 'assert'; import assert from 'assert';
import { delay } from '@umijs/utils';
import { import {
cleanTmpPathExceptCache, cleanTmpPathExceptCache,
getBundleAndConfigs getBundleAndConfigs
@ -171,6 +170,8 @@ export default (api) => {
args: {} args: {}
}); });
const { Server } = require('@umijs/server');
server = new Server({ server = new Server({
...opts, ...opts,
compress: true, compress: true,

View File

@ -1,18 +1,15 @@
import envinfo from 'envinfo';
export default function (api) { export default function (api) {
api.registerCommand({ api.registerCommand({
command: 'info', command: 'info',
description: 'print debugging information about your environment', description: 'print debugging information about your environment',
async fn() { async fn() {
envinfo.run( require('envinfo').run(
{ {
System: ['OS', 'CPU'], System: ['OS', 'CPU'],
Binaries: ['Node', 'Yarn', 'npm'], Binaries: ['Node', 'Yarn', 'npm'],
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
npmPackages: '/**/{typescript,*vue*,@webank/*/}', npmPackages: ['@webank/fes', 'vue', 'vue-router'],
npmGlobalPackages: ['@webank/fes'] npmGlobalPackages: ['@webank/fes']
}, },
{ {