Scale down memory limits and parallelization settings across CI build pipeline. Reduce heap from 8g to 4g, metaspace from 1g to 512m, worker count from 4 to 2, and CMAKE build parallel level from 8 to 4. Remove Gradle caching and update web export to use explicit NODE_OPTIONS for memory allocation. These optimizations reduce resource usage while maintaining stable builds.
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const { withDangerousMod } = require('@expo/config-plugins');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const MAX_JOBS = '4';
|
|
|
|
// React Native's hermes-engine build hardcodes
|
|
// Runtime.getRuntime().availableProcessors()
|
|
// for `cmake --build -j`, ignoring the CMAKE_BUILD_PARALLEL_LEVEL env var.
|
|
// On high-core CI runners this exhausts memory.
|
|
// This plugin caps it during prebuild.
|
|
const withCmakeJobLimit = (config) =>
|
|
withDangerousMod(config, [
|
|
'android',
|
|
async (config) => {
|
|
const root = config.modRequest.projectRoot;
|
|
|
|
const hermesPath = path.join(
|
|
root,
|
|
'node_modules',
|
|
'react-native',
|
|
'ReactAndroid',
|
|
'hermes-engine',
|
|
'build.gradle.kts',
|
|
);
|
|
if (fs.existsSync(hermesPath)) {
|
|
let content = fs.readFileSync(hermesPath, 'utf-8');
|
|
content = content.replace(
|
|
/Runtime\.getRuntime\(\)\.availableProcessors\(\)\.toString\(\)/,
|
|
`"${MAX_JOBS}"`,
|
|
);
|
|
fs.writeFileSync(hermesPath, content);
|
|
console.log(`[withCmakeJobLimit] capped hermes-engine jobs to ${MAX_JOBS}`);
|
|
}
|
|
|
|
return config;
|
|
},
|
|
]);
|
|
|
|
module.exports = withCmakeJobLimit;
|