ts检查 加大内存参数

This commit is contained in:
Wang Kejun 2023-04-12 18:36:11 +08:00
parent 8bcc4d7cf0
commit 292895b328
4 changed files with 61 additions and 34 deletions

View File

@ -33,6 +33,7 @@ const oakPathPlugin = require('../babel-plugin/oakPath');
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
const shouldAnalyze = process.env.COMPILE_ANALYZE === 'true'; const shouldAnalyze = process.env.COMPILE_ANALYZE === 'true';
const memoryLimit = process.env.MEMORY_LIMIT ? Number(process.env.MEMORY_LIMIT) : 4096;
const copyPatterns = [].concat(pkg.copyWebpack || []).map((pattern) => const copyPatterns = [].concat(pkg.copyWebpack || []).map((pattern) =>
typeof pattern === 'string' typeof pattern === 'string'
@ -345,6 +346,7 @@ module.exports = function (webpackEnv) {
}, },
mode: 'write-references', mode: 'write-references',
// profile: true, // profile: true,
memoryLimit,
}, },
issue: { issue: {
// This one is specifically to match during CI tests, // This one is specifically to match during CI tests,

View File

@ -40,6 +40,7 @@ const oakRpxToPxPlugin = require('../postcss-plugin/oakRpxToPx');
// Source maps are resource heavy and can cause out of memory issue for large source files. // Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
const memoryLimit = process.env.MEMORY_LIMIT ? Number(process.env.MEMORY_LIMIT) : 4096;
const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime'); const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');
const reactRefreshWebpackPluginRuntimeEntry = require.resolve( const reactRefreshWebpackPluginRuntimeEntry = require.resolve(
@ -908,7 +909,7 @@ module.exports = function (webpackEnv) {
}, },
mode: 'write-references', mode: 'write-references',
// profile: true, // profile: true,
memoryLimit: 4096, memoryLimit,
}, },
issue: { issue: {
// This one is specifically to match during CI tests, // This one is specifically to match during CI tests,

View File

@ -17,7 +17,9 @@ async function build(cmd) {
? `split:${!!cmd.split}` ? `split:${!!cmd.split}`
: ''}`)}`); : ''}`)}`);
if (cmd.target === 'mp' || cmd.target === 'wechatMp') { if (cmd.target === 'mp' || cmd.target === 'wechatMp') {
const result = cross_spawn_1.default.sync(`cross-env`, [ const result = cross_spawn_1.default.sync(
`cross-env`,
[
`NODE_ENV=${cmd.mode}`, `NODE_ENV=${cmd.mode}`,
`NODE_TARGET=${cmd.target}`, `NODE_TARGET=${cmd.target}`,
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`, `SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
@ -26,14 +28,22 @@ async function build(cmd) {
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`, `GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`, `PROD=${!!cmd.prod}`,
`SPLIT=${!!cmd.split}`, `SPLIT=${!!cmd.split}`,
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
`node`, `node`,
require.resolve(`../scripts/${cmd.mode === 'production' cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
require.resolve(
`../scripts/${
cmd.mode === 'production'
? 'build-mp.js' ? 'build-mp.js'
: 'start-mp.js'}`), : 'start-mp.js'
].filter(Boolean), { }`
),
].filter(Boolean),
{
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
}); }
);
if (result.status === 0) { if (result.status === 0) {
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`执行完成`)}`); (0, tip_style_1.Success)(`${(0, tip_style_1.success)(`执行完成`)}`);
} }
@ -42,7 +52,9 @@ async function build(cmd) {
} }
} }
else if (cmd.target === 'web') { else if (cmd.target === 'web') {
const result = cross_spawn_1.default.sync(`cross-env`, [ const result = cross_spawn_1.default.sync(
`cross-env`,
[
`NODE_ENV=${cmd.mode}`, `NODE_ENV=${cmd.mode}`,
`NODE_TARGET=${cmd.target}`, `NODE_TARGET=${cmd.target}`,
`SUB_DIR_NAME=${cmd.subDir || 'web'}`, `SUB_DIR_NAME=${cmd.subDir || 'web'}`,
@ -50,14 +62,22 @@ async function build(cmd) {
`COMPILE_ANALYZE=${!!cmd.analyze}`, `COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`, `GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`, `PROD=${!!cmd.prod}`,
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
`node`, `node`,
require.resolve(`../scripts/${cmd.mode === 'production' cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
require.resolve(
`../scripts/${
cmd.mode === 'production'
? 'build-web.js' ? 'build-web.js'
: 'start-web.js'}`), : 'start-web.js'
].filter(Boolean), { }`
),
].filter(Boolean),
{
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
}); }
);
if (result.status === 0) { if (result.status === 0) {
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`执行完成`)}`); (0, tip_style_1.Success)(`${(0, tip_style_1.success)(`执行完成`)}`);
} }

View File

@ -46,7 +46,9 @@ export default async function build(cmd: any) {
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`, `GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`, `PROD=${!!cmd.prod}`,
`SPLIT=${!!cmd.split}`, `SPLIT=${!!cmd.split}`,
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
`node`, `node`,
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
require.resolve( require.resolve(
`../scripts/${ `../scripts/${
cmd.mode === 'production' cmd.mode === 'production'
@ -76,7 +78,9 @@ export default async function build(cmd: any) {
`COMPILE_ANALYZE=${!!cmd.analyze}`, `COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`, `GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`, `PROD=${!!cmd.prod}`,
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
`node`, `node`,
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
require.resolve( require.resolve(
`../scripts/${ `../scripts/${
cmd.mode === 'production' cmd.mode === 'production'