Skip to content

Commit 62c4fe1

Browse files
committed
fix(bootstrap): load Intl polyfill before logger to prevent smol build failure
Add Intl polyfill import at the top of bootstrap files before any other imports that use Intl APIs. This fixes the "Intl is not defined" error in smol Node.js builds (ICU-disabled) where logger's stringWidth function uses Intl.Segmenter. Changes: - Copy intl-stub polyfill from cli/src/polyfills to bootstrap package - Import polyfill as first statement in bootstrap-npm.mts and bootstrap-smol.mts - Rebuild bootstrap package to embed polyfill before Intl.Segmenter usage The polyfill checks if globalThis.Intl exists and only installs stubs if missing, making it safe for both ICU-enabled and ICU-disabled builds.
1 parent f05828a commit 62c4fe1

File tree

7 files changed

+100
-89
lines changed

7 files changed

+100
-89
lines changed

packages/bootstrap/dist/bootstrap-npm.js

Lines changed: 44 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bootstrap/dist/bootstrap-smol.js

Lines changed: 44 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bootstrap/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@socketsecurity/build-infra": "workspace:*",
18+
"@socketsecurity/cli": "workspace:*",
1819
"@socketsecurity/lib": "catalog:",
1920
"del-cli": "catalog:",
2021
"esbuild": "catalog:",

packages/bootstrap/src/bootstrap-npm.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* It downloads @socketsecurity/cli from npm and executes it.
66
*/
77

8+
// Load Intl polyfill FIRST for ICU-disabled builds.
9+
import '@socketsecurity/cli/src/polyfills/intl-stub/index.mts'
10+
811
import { logger } from '@socketsecurity/lib/logger'
912

1013
import { findAndExecuteCli, getArgs } from './shared/bootstrap-shared.mjs'

packages/bootstrap/src/bootstrap-smol.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* The smol binary loads this at startup via lib/internal/process/pre_execution.js.
88
*/
99

10+
// Load Intl polyfill FIRST for ICU-disabled builds (smol Node.js).
11+
import '@socketsecurity/cli/src/polyfills/intl-stub/index.mts'
12+
1013
import { logger } from '@socketsecurity/lib/logger'
1114

1215
import { findAndExecuteCli, getArgs } from './shared/bootstrap-shared.mjs'

packages/cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"./bin/yarn-cli.js": "./dist/yarn-cli.js",
2929
"./package.json": "./package.json",
3030
"./data/alert-translations.json": "./data/alert-translations.json",
31-
"./data/command-api-requirements.json": "./data/command-api-requirements.json"
31+
"./data/command-api-requirements.json": "./data/command-api-requirements.json",
32+
"./src/polyfills/intl-stub/*": "./src/polyfills/intl-stub/*"
3233
},
3334
"scripts": {
3435
"build": "node --import=./scripts/load.mjs scripts/build.mjs",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)