Skip to content

Commit 87d8759

Browse files
authored
[TS] Bundle ICU data (#4253)
# Description of Changes Fixes #3926. This PR bundles in icudata (11MB) to the spacetime binary, to allow i18n functions like `String.prototype.localeCompare()` to work. The 2nd commit sets the default locale to [en-001, "International English"](https://www.ctrl.blog/entry/en-001.html), in order to prevent system locale from affecting the execution of reducers. # Expected complexity level and risk 1 # Testing - [x] Verify this fixes the issue.
1 parent a78b056 commit 87d8759

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ uuid = { version = "1.18.1", default-features = false }
325325
# When updating the V8 crate, either update the version and hashes in that file,
326326
# or ping phoebe @gefjon to do so.
327327
v8 = "=145.0.0"
328+
# This version is kept in sync with the version of ICU required by v8.
329+
# When that changes, the `v8::icu::set_common_data_XX()` function is renamed.
330+
deno_core_icudata = "0.77"
328331

329332
walkdir = "2.2.5"
330333
wasmbin = "0.6"

crates/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ bytestring.workspace = true
5151
chrono.workspace = true
5252
crossbeam-channel.workspace = true
5353
crossbeam-queue.workspace = true
54+
deno_core_icudata.workspace = true
5455
derive_more.workspace = true
5556
dirs.workspace = true
5657
enum-as-inner.workspace = true

crates/core/src/host/v8/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ impl V8RuntimeInner {
104104
///
105105
/// Should only be called once but it isn't unsound to call it more times.
106106
fn init() -> Self {
107+
// If the number in the name of this function is changed, update the version
108+
// of the `deno_core_icudata` dep to match the number in the function name.
109+
v8::icu::set_common_data_77(deno_core_icudata::ICU_DATA).ok();
110+
// Set a default locale for functions like `toLocaleString()`.
111+
// en-001 is "International English". <https://www.ctrl.blog/entry/en-001.html>
112+
v8::icu::set_default_locale("en-001");
113+
107114
// We don't want idle tasks nor background worker tasks,
108115
// as we intend to run on a single core.
109116
// Per the docs, `new_single_threaded_default_platform` requires

0 commit comments

Comments
 (0)