From 0a8f4e0c3d2a60d8dadcd224a4db4a91fa3f41ca Mon Sep 17 00:00:00 2001 From: Crimson Date: Wed, 6 May 2026 00:05:03 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20memory=20policy=20=D0=B4=D0=BB=D1=8F=20frontend=20buil?= =?UTF-8?q?d=20=D0=B2=20builder=20=D0=B8=20=D0=B7=D0=B0=D0=B4=D0=BE=D0=BA?= =?UTF-8?q?=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20override?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/build/README.md | 23 +++++++++++++++++++++++ tools/build/lib/package.sh | 11 +++++++++++ 2 files changed, 34 insertions(+) diff --git a/tools/build/README.md b/tools/build/README.md index dec6568..41b8e70 100644 --- a/tools/build/README.md +++ b/tools/build/README.md @@ -176,9 +176,32 @@ If frozen install fails, update dependencies intentionally in source control and - `PACKAGE_VERSION=0.1.6` - `BUILD_ID=prod-$(date -u +%Y%m%dT%H%M%SZ)` - `BUN_FLAVOR=auto|x64|x64-baseline` +- `FRONTEND_NODE_OLD_SPACE_SIZE=2048` (default memory limit for frontend build step) - `TOOLCHAIN_DIR=/custom/path/.toolchain` - `VERIFY_TOOLCHAIN_CHECKSUMS=true` +## Frontend memory policy + +Builder applies a safe default Node.js heap limit for frontend build inside [`bundle_ui()`](lib/package.sh): + +```bash +--max-old-space-size=2048 +``` + +Override options: + +- adjust default value for this policy: + +```bash +FRONTEND_NODE_OLD_SPACE_SIZE=3072 ./tools/build/build.sh +``` + +- or provide full custom Node options (if `--max-old-space-size` is already set there, builder will not append another one): + +```bash +NODE_OPTIONS="--max-old-space-size=3072" ./tools/build/build.sh +``` + ## Диагностика Проверить AVX2: diff --git a/tools/build/lib/package.sh b/tools/build/lib/package.sh index 95022c9..09e4356 100644 --- a/tools/build/lib/package.sh +++ b/tools/build/lib/package.sh @@ -47,6 +47,17 @@ bundle_ui() { ( cd "$ui_src/frontend" + + local frontend_node_old_space_size="${FRONTEND_NODE_OLD_SPACE_SIZE:-2048}" + local frontend_node_options="${NODE_OPTIONS:-}" + + if [[ "$frontend_node_options" != *"--max-old-space-size="* ]]; then + frontend_node_options="${frontend_node_options:+$frontend_node_options }--max-old-space-size=${frontend_node_old_space_size}" + fi + + export NODE_OPTIONS="$frontend_node_options" + log_info "Frontend Node.js options: $NODE_OPTIONS" + "$PNPM_BIN" install --frozen-lockfile "$PNPM_BIN" run build:prod )