From f8c03ff00f709179d580b183f7fb5ed55b810c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E7=BA=AF?= Date: Wed, 3 Feb 2021 10:13:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96fes=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=9A=84=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 编写命令时,比较大的库需要使用require的方式按需加载 --- packages/fes-plugin-jest/src/index.js | 4 +++- .../fes-preset-built-in/src/plugins/commands/dev/index.js | 5 +++-- .../fes-preset-built-in/src/plugins/commands/info/index.js | 7 ++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/fes-plugin-jest/src/index.js b/packages/fes-plugin-jest/src/index.js index cce830f2..5e88cdb3 100644 --- a/packages/fes-plugin-jest/src/index.js +++ b/packages/fes-plugin-jest/src/index.js @@ -1,4 +1,4 @@ -import { runCLI } from 'jest'; + import assert from 'assert'; import { join } from 'path'; import { existsSync } from 'fs'; @@ -71,6 +71,8 @@ export default function (api) { }, {}); args.debug && logger.log(`config from args: ${JSON.stringify(argsConfig)}`); + // 比较大的库建议使用require,使用时才加载,提升fes命令的效率 + const { runCLI } = require('jest'); // Run jest const result = await runCLI( { diff --git a/packages/fes-preset-built-in/src/plugins/commands/dev/index.js b/packages/fes-preset-built-in/src/plugins/commands/dev/index.js index 1c6342d4..7275508f 100644 --- a/packages/fes-preset-built-in/src/plugins/commands/dev/index.js +++ b/packages/fes-preset-built-in/src/plugins/commands/dev/index.js @@ -1,6 +1,5 @@ -import { Server } from '@umijs/server'; -import { delay } from '@umijs/utils'; import assert from 'assert'; +import { delay } from '@umijs/utils'; import { cleanTmpPathExceptCache, getBundleAndConfigs @@ -171,6 +170,8 @@ export default (api) => { args: {} }); + const { Server } = require('@umijs/server'); + server = new Server({ ...opts, compress: true, diff --git a/packages/fes-preset-built-in/src/plugins/commands/info/index.js b/packages/fes-preset-built-in/src/plugins/commands/info/index.js index ff01b352..a8e84e5e 100644 --- a/packages/fes-preset-built-in/src/plugins/commands/info/index.js +++ b/packages/fes-preset-built-in/src/plugins/commands/info/index.js @@ -1,18 +1,15 @@ - -import envinfo from 'envinfo'; - export default function (api) { api.registerCommand({ command: 'info', description: 'print debugging information about your environment', async fn() { - envinfo.run( + require('envinfo').run( { System: ['OS', 'CPU'], Binaries: ['Node', 'Yarn', 'npm'], Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], - npmPackages: '/**/{typescript,*vue*,@webank/*/}', + npmPackages: ['@webank/fes', 'vue', 'vue-router'], npmGlobalPackages: ['@webank/fes'] }, {