Public repository: timo / feel

Reader

An interpreter of FEEL, written in Rust, with integrations for PostgreSQL, WASM, Lua, and Python.

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>
Changeset226f9e32f9a38716c32bcb702c6e1d9b1db4238d
Author (claimed)Timo Stolz <timo.stolz@gmail.com>,
Parents2ee94987b164
Children
Pushlog
by timo via ssh

modified Cargo.lock +1 −10

@@ -1002,7 +1002,7 @@
10021002
 checksum = "4603d3033e49e2b0e31229fcab20a5d40089c607d975cd9c80551dc69eed9102"
10031003
 dependencies = [
10041004
  "jiff-static",
1005
- "jiff-tzdb-platform",
1005
+ "jiff-tzdb",
10061006
  "log",
10071007
  "portable-atomic",
10081008
  "portable-atomic-util",
@@ -1026,15 +1026,6 @@
10261026
 version = "0.1.6"
10271027
 source = "registry+https://github.com/rust-lang/crates.io-index"
10281028
 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
-]
10381029
 
10391030
 [[package]]
10401031
 name = "js-sys"

modified Cargo.toml +6 −4

@@ -32,7 +32,9 @@
3232
 regex = "1"
3333
 serde_json = "1"
3434
 # 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 @@
414414
 - **Decision:**
415415
   - **Library `jiff` (RD-/portable, ADR-1 holds).** Its calendar-aware `Span` /
416416
     `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.
420426
   - **Five flat `Value` variants** (matching the existing flat style): `Date`,
421427
     `Time`, `DateTime` (each civil value + an optional zone preserved verbatim for
422428
     output: `Z` vs `+00:00` vs `@Area/City`), `YearsMonthsDuration(i64 months)`,
@@ -454,10 +460,10 @@
454460
     context input.
455461
 - **Consequence:** Reverses ADR-5's deferral; the `temporal-interval-mapping`
456462
   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).
461467
 - **Deviations (deliberate, documented):** jiff caps the year at ±9999 and its
462468
   `Span` caps the years/months magnitude, so the TCK's extreme-range
463469
   dates/durations (and the odd `duration("PT0.S")` lexical form) cannot round-trip;
@@ -527,6 +533,23 @@
527533
   Datum via `IntoDatum` (never calling an `ereport`-ing C function), mapping an
528534
   out-of-range value to SQL NULL rather than risking a longjmp.
529535
 
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
+
530553
 ## Roadmap: deferred scope (recorded, not yet built)
531554
 
532555
 These were considered and deliberately deferred to keep the slice thin. Listed so

modified README.md +4 −1

@@ -33,7 +33,10 @@
3333
   `.time offset`, …), the temporal constructor and component built-ins
3434
   (`date(…)`, `day of week(…)`, …), and `now()` / `today()` (ADR-18). Values
3535
   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).
3740
 
3841
 Still out of scope: unary tests (the non-interval `in` forms), special characters
3942
 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 @@
99
 lalrpop-util.workspace = true
1010
 logos.workspace = true
1111
 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"] }
1317
 # Only the `rust-regex` provider needs the `regex` crate; targets that bring
1418
 # their own host engine (e.g. feel-wasm's JS RegExp) build without it.
1519
 regex = { workspace = true, optional = true }
1620
 
1721
 [features]
1822
 # `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"]
2128
 rust-regex = ["dep:regex"]
29
+tzdb-bundle = ["jiff/tzdb-bundle-always"]
2230
 
2331
 [build-dependencies]
2432
 lalrpop.workspace = true

modified crates/feel-pg/Cargo.toml +4 −2

@@ -24,8 +24,10 @@
2424
 serde_json.workspace = true
2525
 feel-core = { path = "../feel-core" }
2626
 # 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"] }
2931
 
3032
 [dev-dependencies]
3133
 pgrx-tests = "=0.18.1"

modified crates/feel-wasm/Cargo.toml +11 −6

@@ -16,15 +16,20 @@
1616
 # JS `Date` interop (ADR-18): detect `Date` in the context input and return
1717
 # date/date-and-time results as `Date` objects; also the `now()` clock source.
1818
 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).
2526
 feel-core = { path = "../feel-core", default-features = false }
2627
 
2728
 [features]
2829
 # Purist opt-in: re-bundle the Rust `regex` engine instead of the JS dialect, for
2930
 # byte-identical regex results across targets — at the regex stack's size cost.
3031
 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"]