嵌入 ICU 数据的有界集(small-icu)
此选项静态地生成针对 ICU 库的二进制链接,并在 node
可执行文件中包含 ICU 数据的子集(通常只有英文区域设置)。
small-icu
完全支持仅需要 ICU 库本身的功能,例如 String.prototype.normalize()
和 WHATWG 网址解析器。
另外需要 ICU 语言环境数据的特性,比如 Intl.DateTimeFormat
,一般只适用于英文语言环境:
const january = new Date(9e8);
const english = new Intl.DateTimeFormat('en', { month: 'long' });
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
console.log(english.format(january));
// 打印 "January"
console.log(spanish.format(january));
// 在 small-icu 上打印 "M01"
// 应该打印 "enero"
此模式提供了特性和二进制大小之间的平衡。
This option makes the resulting binary link against the ICU library statically,
and includes a subset of ICU data (typically only the English locale) within
the node
executable.
Functionalities that only require the ICU library itself, such as
String.prototype.normalize()
and the WHATWG URL parser, are fully
supported under small-icu
. Features that require ICU locale data in addition,
such as Intl.DateTimeFormat
, generally only work with the English locale:
const january = new Date(9e8);
const english = new Intl.DateTimeFormat('en', { month: 'long' });
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
console.log(english.format(january));
// Prints "January"
console.log(spanish.format(january));
// Prints "M01" on small-icu
// Should print "enero"
This mode provides a balance between features and binary size.