feat(wasm): gate the IANA tzdb behind a feature; default WASM to offset-only
public
feat(wasm): gate the IANA tzdb behind a feature; default WASM to offset-only Mirror ADR-16's regex split for the tz database (ADR-18 / RD-3): jiff is pinned `default-features = false` at the workspace, feel-core re-adds its non-tzdb defaults plus a default `tzdb-bundle` feature (so native builds and feel-pg keep full named-zone support), and feel-wasm builds without it. The default WASM bundle is now offset-only — `+02:00`/`Z` work, a named zone (`@Europe/Paris`) evaluates to null — at ~479 KB instead of ~738 KB. Full named-zone support is one flag away: `--features iana-tz` (~723 KB). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Changeset | 226f9e32f9a38716c32bcb702c6e1d9b1db4238d |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@gmail.com>, |
| Parents | 2ee94987b164 |
| Children | |
| Pushlog | by timo via ssh |
modified Cargo.lock +1 −10
| @@ -1002,7 +1002,7 @@ | ||
| 1002 | 1002 | checksum = "4603d3033e49e2b0e31229fcab20a5d40089c607d975cd9c80551dc69eed9102" |
| 1003 | 1003 | dependencies = [ |
| 1004 | 1004 | "jiff-static", |
| 1005 | - "jiff-tzdb-platform", | |
| 1005 | + "jiff-tzdb", | |
| 1006 | 1006 | "log", |
| 1007 | 1007 | "portable-atomic", |
| 1008 | 1008 | "portable-atomic-util", |
| @@ -1026,15 +1026,6 @@ | ||
| 1026 | 1026 | version = "0.1.6" |
| 1027 | 1027 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1028 | 1028 | checksum = "c900ef84826f1338a557697dc8fc601df9ca9af4ac137c7fb61d4c6f2dfd3076" |
| 1029 | - | |
| 1030 | -[[package]] | |
| 1031 | -name = "jiff-tzdb-platform" | |
| 1032 | -version = "0.1.3" | |
| 1033 | -source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1034 | -checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" | |
| 1035 | -dependencies = [ | |
| 1036 | - "jiff-tzdb", | |
| 1037 | -] | |
| 1038 | 1029 | |
| 1039 | 1030 | [[package]] |
| 1040 | 1031 | name = "js-sys" |
modified Cargo.toml +6 −4
| @@ -32,7 +32,9 @@ | ||
| 32 | 32 | regex = "1" |
| 33 | 33 | serde_json = "1" |
| 34 | 34 | # Temporal types (ADR-18). Calendar-aware (`Span`/`SignedDuration` map onto FEEL's |
| 35 | -# two duration kinds), nanosecond precision, ISO-8601 parse/format, and a bundled | |
| 36 | -# IANA tzdb on platforms without a system one (wasm). Portable, so ADR-1 holds — | |
| 37 | -# feel-core never enables jiff's wasm-bindgen-pulling `js` feature; feel-wasm does. | |
| 38 | -jiff = "0.2" | |
| 35 | +# two duration kinds), nanosecond precision, ISO-8601 parse/format. Portable, so | |
| 36 | +# ADR-1 holds. `default-features = false` here (it is only honoured at the | |
| 37 | +# workspace level) so the embedded IANA tzdb is opt-in per crate via feature | |
| 38 | +# flags — keeping it out of the WASM bundle by default; each member enables the | |
| 39 | +# jiff features it needs. | |
| 40 | +jiff = { version = "0.2", default-features = false } | |
modified DECISIONS.md +30 −7
| @@ -414,9 +414,15 @@ | ||
| 414 | 414 | - **Decision:** |
| 415 | 415 | - **Library `jiff` (RD-/portable, ADR-1 holds).** Its calendar-aware `Span` / |
| 416 | 416 | `SignedDuration` map cleanly onto FEEL's two *distinct* duration types, it has |
| 417 | - nanosecond precision, ISO-8601 parse/format, and a bundled IANA tzdb on | |
| 418 | - platforms without a system one (so WASM gets named zones). feel-core never | |
| 419 | - enables jiff's wasm-bindgen-pulling `js` feature; the wrappers do. | |
| 417 | + nanosecond precision, and ISO-8601 parse/format. feel-core never enables | |
| 418 | + jiff's wasm-bindgen-pulling `js` feature; the wrappers do. The embedded IANA | |
| 419 | + tzdb (needed only to resolve *named* zones like `@Europe/Paris` where there is | |
| 420 | + no system tzdb, i.e. on wasm) is **opt-in** behind a feature flag, mirroring | |
| 421 | + ADR-16's regex split: feel-core's default `tzdb-bundle` feature embeds it | |
| 422 | + (native builds and feel-pg get full zones; native also has the system tzdb); | |
| 423 | + feel-wasm builds `default-features = false` and so is **offset-only** by | |
| 424 | + default (`+02:00`/`Z` work, a named zone evaluates to null), re-enabling the | |
| 425 | + bundle via its `iana-tz` feature. | |
| 420 | 426 | - **Five flat `Value` variants** (matching the existing flat style): `Date`, |
| 421 | 427 | `Time`, `DateTime` (each civil value + an optional zone preserved verbatim for |
| 422 | 428 | output: `Z` vs `+00:00` vs `@Area/City`), `YearsMonthsDuration(i64 months)`, |
| @@ -454,10 +460,10 @@ | ||
| 454 | 460 | context input. |
| 455 | 461 | - **Consequence:** Reverses ADR-5's deferral; the `temporal-interval-mapping` |
| 456 | 462 | deviation is now live. Ingested 0007, 0095–0098, 1115–1117, 1120–1121 and the |
| 457 | - temporal halves of 0100/0075/0099: **672 → 1709 fixture cases**. The WASM bundle | |
| 458 | - grows ~272 KB → ~738 KB (the bundled IANA tzdb — the accepted cost of full | |
| 459 | - zone-name support). ADR-1 is intact (`cargo tree -p feel-core` shows no | |
| 460 | - pgrx/wasm-bindgen). | |
| 463 | + temporal halves of 0100/0075/0099: **672 → 1709 fixture cases**. The default | |
| 464 | + WASM bundle grows ~272 KB → ~479 KB (the jiff date/time code, no tzdb); | |
| 465 | + `--features iana-tz` adds the tzdb for ~723 KB. ADR-1 is intact (`cargo tree -p | |
| 466 | + feel-core` shows no pgrx/wasm-bindgen). | |
| 461 | 467 | - **Deviations (deliberate, documented):** jiff caps the year at ±9999 and its |
| 462 | 468 | `Span` caps the years/months magnitude, so the TCK's extreme-range |
| 463 | 469 | dates/durations (and the odd `duration("PT0.S")` lexical form) cannot round-trip; |
| @@ -527,6 +533,23 @@ | ||
| 527 | 533 | Datum via `IntoDatum` (never calling an `ereport`-ing C function), mapping an |
| 528 | 534 | out-of-range value to SQL NULL rather than risking a longjmp. |
| 529 | 535 | |
| 536 | +### RD-3: feel-wasm is offset-only by default (the IANA tzdb is opt-in) | |
| 537 | + | |
| 538 | +- **Weighed:** ADR-18 makes the embedded IANA tzdb a feature flag. The bundle is | |
| 539 | + ~258 KB of data — over half the WASM module. Most FEEL expressions that use | |
| 540 | + zones use a numeric offset (`+02:00`) or `Z`, which need no tzdb; only | |
| 541 | + *named*-zone literals/lookups (`@Europe/Paris`) do. Against bundling by default: | |
| 542 | + the size dominates a module that is otherwise ~479 KB. Against *not* bundling: | |
| 543 | + named zones silently become null in the default build. | |
| 544 | +- **Decision (2026-06-16):** feel-wasm defaults to **offset-only** (no tzdb; | |
| 545 | + ~479 KB); named zones evaluate to null. Full named-zone support is one flag away | |
| 546 | + — `wasm-pack build … -- --features iana-tz` (~723 KB). feel-pg and native builds | |
| 547 | + keep the bundle (size is irrelevant there), so they are unaffected. | |
| 548 | +- **Revisit trigger:** named zones become common enough in WASM use that null is a | |
| 549 | + surprise — then flip feel-wasm's default to include `iana-tz`. | |
| 550 | +- **If flipped:** add `iana-tz` to a `default` feature on feel-wasm (or document | |
| 551 | + building with it), accepting the larger default bundle. | |
| 552 | + | |
| 530 | 553 | ## Roadmap: deferred scope (recorded, not yet built) |
| 531 | 554 | |
| 532 | 555 | These were considered and deliberately deferred to keep the slice thin. Listed so |
modified README.md +4 −1
| @@ -33,7 +33,10 @@ | ||
| 33 | 33 | `.time offset`, …), the temporal constructor and component built-ins |
| 34 | 34 | (`date(…)`, `day of week(…)`, …), and `now()` / `today()` (ADR-18). Values |
| 35 | 35 | cross the boundary as canonical ISO-8601 (native PostgreSQL `date`/`timestamptz`/ |
| 36 | - `interval` casts; WASM `Date` objects). | |
| 36 | + `interval` casts; WASM `Date` objects). Named zones (`@Europe/Paris`) need the | |
| 37 | + IANA tzdb: bundled on native / feel-pg, and in WASM via an opt-in feature — | |
| 38 | + `wasm-pack build crates/feel-wasm --target nodejs -- --features iana-tz` (~723 KB | |
| 39 | + vs the ~479 KB offset-only default, where a named zone evaluates to null). | |
| 37 | 40 | |
| 38 | 41 | Still out of scope: unary tests (the non-interval `in` forms), special characters |
| 39 | 42 | in names, and user-defined functions. See [DECISIONS.md](DECISIONS.md) for the |
modified crates/feel-core/Cargo.toml +11 −3
| @@ -9,16 +9,24 @@ | ||
| 9 | 9 | lalrpop-util.workspace = true |
| 10 | 10 | logos.workspace = true |
| 11 | 11 | unicode-ident.workspace = true |
| 12 | -jiff.workspace = true | |
| 12 | +# The workspace pins jiff to `default-features = false`, so the embedded IANA tzdb | |
| 13 | +# is opt-in (the `tzdb-bundle` feature), keeping ~466 KB out of the WASM bundle by | |
| 14 | +# default (ADR-18). These base features re-add jiff's non-tzdb defaults plus the | |
| 15 | +# *system* tzdb on native; only named-zone lookups need a bundled tzdb. | |
| 16 | +jiff = { workspace = true, features = ["std", "tz-system", "tz-fat", "tzdb-zoneinfo", "tzdb-concatenated", "perf-inline"] } | |
| 13 | 17 | # Only the `rust-regex` provider needs the `regex` crate; targets that bring |
| 14 | 18 | # their own host engine (e.g. feel-wasm's JS RegExp) build without it. |
| 15 | 19 | regex = { workspace = true, optional = true } |
| 16 | 20 | |
| 17 | 21 | [features] |
| 18 | 22 | # `rust-regex` bundles the Rust `regex` engine as the default FeelRegex provider |
| 19 | -# (ADR-16). Disable it (`--no-default-features`) when the host supplies its own. | |
| 20 | -default = ["rust-regex"] | |
| 23 | +# (ADR-16). `tzdb-bundle` embeds the IANA tzdb so named zones (`@Europe/Paris`) | |
| 24 | +# resolve even without a system tzdb (i.e. on wasm); see ADR-18. Both are on by | |
| 25 | +# default (native builds + feel-pg); feel-wasm disables them (`default-features = | |
| 26 | +# false`) and re-enables each via its own `xpath-regex` / `iana-tz` features. | |
| 27 | +default = ["rust-regex", "tzdb-bundle"] | |
| 21 | 28 | rust-regex = ["dep:regex"] |
| 29 | +tzdb-bundle = ["jiff/tzdb-bundle-always"] | |
| 22 | 30 | |
| 23 | 31 | [build-dependencies] |
| 24 | 32 | lalrpop.workspace = true |
modified crates/feel-pg/Cargo.toml +4 −2
| @@ -24,8 +24,10 @@ | ||
| 24 | 24 | serde_json.workspace = true |
| 25 | 25 | feel-core = { path = "../feel-core" } |
| 26 | 26 | # Used only to build the `EvalEnv` instant from the transaction start timestamp |
| 27 | -# (ADR-18); the temporal value logic itself lives in feel-core. | |
| 28 | -jiff.workspace = true | |
| 27 | +# (ADR-18); the temporal value logic — and the IANA tzdb bundle (via feel-core's | |
| 28 | +# default `tzdb-bundle` feature) — lives in feel-core. Server-side size is | |
| 29 | +# irrelevant, so feel-pg keeps the bundle for host-independent named zones. | |
| 30 | +jiff = { workspace = true, features = ["std"] } | |
| 29 | 31 | |
| 30 | 32 | [dev-dependencies] |
| 31 | 33 | pgrx-tests = "=0.18.1" |
modified crates/feel-wasm/Cargo.toml +11 −6
| @@ -16,15 +16,20 @@ | ||
| 16 | 16 | # JS `Date` interop (ADR-18): detect `Date` in the context input and return |
| 17 | 17 | # date/date-and-time results as `Date` objects; also the `now()` clock source. |
| 18 | 18 | js-sys = "0.3" |
| 19 | -# Build the `EvalEnv` instant from `Date.now()` and parse the boundary form; the | |
| 20 | -# temporal value logic itself lives in feel-core. | |
| 21 | -jiff.workspace = true | |
| 22 | -# default-features = false drops feel-core's `rust-regex` provider (and the whole | |
| 23 | -# regex-automata stack) from the bundle; the regex builtins use the host JS | |
| 24 | -# `RegExp` engine instead (ADR-16). | |
| 19 | +# Build the `EvalEnv` instant from `Date.now()`; no tzdb needed here (the temporal | |
| 20 | +# value logic, and the optional tzdb bundle, live in feel-core). | |
| 21 | +jiff = { workspace = true, features = ["std"] } | |
| 22 | +# default-features = false drops feel-core's `rust-regex` provider (the whole | |
| 23 | +# regex-automata stack) AND the embedded IANA tzdb from the bundle; the regex | |
| 24 | +# builtins use the host JS `RegExp` engine, and temporal is offset-only by default | |
| 25 | +# (named zones -> null) (ADR-16/ADR-18). | |
| 25 | 26 | feel-core = { path = "../feel-core", default-features = false } |
| 26 | 27 | |
| 27 | 28 | [features] |
| 28 | 29 | # Purist opt-in: re-bundle the Rust `regex` engine instead of the JS dialect, for |
| 29 | 30 | # byte-identical regex results across targets — at the regex stack's size cost. |
| 30 | 31 | xpath-regex = ["feel-core/rust-regex"] |
| 32 | +# Opt-in: embed the IANA tzdb so named zones (`@Europe/Paris`) resolve in WASM, at | |
| 33 | +# ~466 KB of bundle. The default build is offset-only — `+02:00`/`Z` work, named | |
| 34 | +# zones evaluate to null (ADR-18). | |
| 35 | +iana-tz = ["feel-core/tzdb-bundle"] | |