Skip to content

Conversation

@Shreyas2004wagh
Copy link

Stabilizes Windows Rollup builds by limiting Terser worker parallelism to avoid OOM and worker spawn failures.

Windows Rollup Build Stability

Acceptance Criteria fulfillment

  • Reproduced intermittent Windows build failures in Rollup minification (Call retries were exceeded, spawn UNKNOWN, OOM).
  • Updated Rollup configs to use conservative Terser worker settings (numWorkers: 1) in affected packages.
  • Verified local builds succeed for impacted packages after change.

Fixes #1137

What changed

This PR limits terser worker parallelism to avoid Windows process/memory pressure:

  • packages/markups/rollup.config.js
  • packages/react/rollup.config.js
  • packages/ui-elements/rollup.config.js
  • packages/ui-kit/rollup.config.js

Each now uses:

  • const TERSER_OPTIONS = { numWorkers: 1 }
  • terser(TERSER_OPTIONS) in build outputs.

Why this is safe

This is a conservative build-time-only change.
It preserves deterministic output and does not change runtime behavior of the packages.

PR Test Details

Validated locally on Windows with Node 16.19.0 / Yarn 3.6.4:

  • yarn workspace @embeddedchat/markups build
  • yarn workspace @embeddedchat/ui-elements build
  • yarn workspace @embeddedchat/ui-kit build
  • yarn workspace @embeddedchat/react build

Notes:

  • Root yarn build may still fail in low-disk environments due to unrelated ENOSPC (disk space) errors.

Copilot AI review requested due to automatic review settings February 8, 2026 10:29
@CLAassistant
Copy link

CLAassistant commented Feb 8, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to stabilize Rollup production builds on Windows by reducing Terser parallelism, mitigating intermittent worker spawn failures and OOM conditions during minification (Fixes #1137).

Changes:

  • Introduces a shared TERSER_OPTIONS constant with numWorkers: 1 in affected packages’ Rollup configs.
  • Updates production minification steps to call terser(TERSER_OPTIONS) instead of terser().

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
packages/markups/rollup.config.js Limits Terser worker count during production minification.
packages/react/rollup.config.js Limits Terser worker count for both CJS and ESM production outputs.
packages/ui-elements/rollup.config.js Limits Terser worker count during production minification.
packages/ui-kit/rollup.config.js Limits Terser worker count during production minification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import dts from 'rollup-plugin-dts';

const PRODUCTION = process.env.NODE_ENV === 'production';
const TERSER_OPTIONS = { numWorkers: 1 };
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.

Suggested change
const TERSER_OPTIONS = { numWorkers: 1 };
const TERSER_NUM_WORKERS_ENV = process.env.TERSER_NUM_WORKERS;
const TERSER_NUM_WORKERS =
TERSER_NUM_WORKERS_ENV && !Number.isNaN(Number(TERSER_NUM_WORKERS_ENV))
? Number(TERSER_NUM_WORKERS_ENV)
: process.platform === 'win32'
? 1
: undefined;
const TERSER_OPTIONS = TERSER_NUM_WORKERS
? { numWorkers: TERSER_NUM_WORKERS }
: {};

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I kept this unconditional intentionally to prioritize build stability and keep the change minimal.
Happy to make it platform-specific or configurable if that’s preferred by maintainers.

import dts from 'rollup-plugin-dts';

const PRODUCTION = process.env.NODE_ENV === 'production';
const TERSER_OPTIONS = { numWorkers: 1 };
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.

Suggested change
const TERSER_OPTIONS = { numWorkers: 1 };
const TERSER_OPTIONS =
process.platform === 'win32' ? { numWorkers: 1 } : {};

Copilot uses AI. Check for mistakes.

const packageJson = require('./package.json');
const PRODUCTION = process.env.NODE_ENV === 'production';
const TERSER_OPTIONS = { numWorkers: 1 };
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.

Suggested change
const TERSER_OPTIONS = { numWorkers: 1 };
const TERSER_NUM_WORKERS = process.env.TERSER_NUM_WORKERS;
const TERSER_OPTIONS =
TERSER_NUM_WORKERS != null && TERSER_NUM_WORKERS !== ''
? { numWorkers: Number(TERSER_NUM_WORKERS) }
: process.platform === 'win32'
? { numWorkers: 1 }
: {};

Copilot uses AI. Check for mistakes.
import dts from 'rollup-plugin-dts';

const PRODUCTION = process.env.NODE_ENV === 'production';
const TERSER_OPTIONS = { numWorkers: 1 };
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.

Suggested change
const TERSER_OPTIONS = { numWorkers: 1 };
const TERSER_NUM_WORKERS =
process.env.TERSER_NUM_WORKERS &&
parseInt(process.env.TERSER_NUM_WORKERS, 10);
const TERSER_OPTIONS =
Number.isInteger(TERSER_NUM_WORKERS) && TERSER_NUM_WORKERS > 0
? { numWorkers: TERSER_NUM_WORKERS }
: process.platform === 'win32'
? { numWorkers: 1 }
: {};

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows builds fail intermittently due to Rollup Terser worker crashes and OOM

2 participants