From cb651adfafa1c3b9568a2ffa25fc9a887ab40049 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 15 Jul 2025 20:00:41 -0700 Subject: [PATCH] Run library build one at a time to avoid OOM on Netlify --- package.json | 1 + packages/webamp/scripts/rollup.mjs | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 778c7acc..73760173 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "lint": "eslint . --ext ts,tsx,js,jsx --rulesdir=packages/webamp-modern/tools/eslint-rules", "type-check": "pnpm --filter webamp type-check && pnpm --filter ani-cursor type-check && pnpm --filter skin-database type-check && pnpm --filter webamp-docs type-check && pnpm --filter winamp-eqf type-check", "deploy": "npx turbo webamp#build webamp-modern#build --concurrency 1 && mv packages/webamp-modern/build packages/webamp/dist/demo-site/modern", + "deploy-docs": "npx turbo webamp-docs#build", "format": "prettier --write '**/*.{js,ts,tsx}'" }, "devDependencies": { diff --git a/packages/webamp/scripts/rollup.mjs b/packages/webamp/scripts/rollup.mjs index 150f020b..5bfb4a2b 100644 --- a/packages/webamp/scripts/rollup.mjs +++ b/packages/webamp/scripts/rollup.mjs @@ -88,12 +88,32 @@ const BUNDLES = [ }, ]; +const PARALLEL_LIMIT = 1; + build(); async function build() { - console.log(`🚀 Building ${BUNDLES.length} bundles in parallel...`); + console.log( + `🚀 Building ${BUNDLES.length} bundles in parallel (limit: ${PARALLEL_LIMIT})...` + ); - const buildPromises = BUNDLES.map(async (bundleDesc) => { + let index = 0; + async function nextBatch() { + const batch = []; + for ( + let i = 0; + i < PARALLEL_LIMIT && index < BUNDLES.length; + i++, index++ + ) { + batch.push(runBundle(BUNDLES[index])); + } + await Promise.all(batch); + if (index < BUNDLES.length) { + await nextBatch(); + } + } + + async function runBundle(bundleDesc) { console.log(`📦 Building ${bundleDesc.name}...`); const plugins = getPlugins({ outputFile: bundleDesc.output.file, @@ -136,8 +156,8 @@ async function build() { ...bundleDesc.output, }); console.log(`✅ Completed ${bundleDesc.name}`); - }); + } - await Promise.all(buildPromises); + await nextBatch(); console.log(`🎉 All ${BUNDLES.length} bundles built successfully!`); }