Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/perry-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ intl-segmenter = ["dep:unicode-segmentation"]
# it (the compiler enables it on `Intl.getCanonicalLocales`/`supportedLocalesOf`
# usage). Already pulled transitively by `temporal`, so default/shipped builds
# carry no extra weight. A hand-rolled structural fallback covers the off case.
intl-locale = ["dep:icu_locale_core"]
# `icu_locale_core/alloc` is required for `Locale::try_from_str`/`normalize` and
# the mutable `Keywords`/`Variants` builders `Intl.Locale` uses; without it the
# auto-optimize build of a Temporal-free program that touches `Intl.Locale`
# would fail (alloc was previously only pulled in transitively by `temporal`).
intl-locale = ["dep:icu_locale_core", "icu_locale_core/alloc"]
# `full` only opt-ins the small Node-API helpers (os.hostname / os.homedir).
# `postgres`, `redis`, `whoami` were previously listed here but were either
# unimported (postgres, whoami) or only used by a now-deleted `redis_client.rs`
Expand Down
18 changes: 18 additions & 0 deletions crates/perry-runtime/src/intl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,19 @@ fn set_proto_to_string_tag(proto: *mut ObjectHeader, tag: &str) {
);
}

// ---- Intl.Locale -----------------------------------------------------------
// Implemented in the `locale` submodule (gated on `intl-locale`); kept separate
// so `intl.rs` stays under the file-size gate.
#[cfg(feature = "intl-locale")]
mod locale;
#[cfg(feature = "intl-locale")]
pub(crate) use locale::{install_locale_constructor, is_locale_ctor};

#[cfg(not(feature = "intl-locale"))]
pub(crate) fn is_locale_ctor(_func_value: f64) -> bool {
false
}

fn install_constructor(
ns_obj: *mut ObjectHeader,
name: &str,
Expand Down Expand Up @@ -1831,4 +1844,9 @@ pub fn install_intl_namespace(ns_obj: *mut ObjectHeader) {
),
],
);
// `Intl.Locale` needs the `icu_locale_core` BCP-47 parser (gated on the
// `intl-locale` feature, enabled by the compiler when a program references
// `Intl.Locale`).
#[cfg(feature = "intl-locale")]
install_locale_constructor(ns_obj);
}
Loading