docs: TOML date/time values in bundles compile to Temporal calls - #39120
docs: TOML date/time values in bundles compile to Temporal calls#39120robobun wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
|
Updated 9:56 AM PT - Aug 15th, 2026
✅ @robobun, your commit b98110242c1aa243e21f40c7d70a4b5afe9da452 passed in 🧪 To try this PR locally: bunx bun-pr 39120That installs a local version of the PR into your bun-39120 --bun |
|
Status: docs-only, CI green (Format, Lint, Buildkite #98335), no review findings to address. Ready for a maintainer.
|
There was a problem hiding this comment.
LGTM — docs-only addition documenting that bundled TOML date/time values compile to Temporal.*.from() calls.
What was reviewed:
- Verified against
src/js_parser/parse/parse_entry.rs:lower_toml_datetimesis set fromloader == Loader::Tomlalone (not target-gated), and the lowering emitsTemporal.<class>.from(...)withCallUnwrap::IfUnused(the@__PURE__annotation), matching the example output and the tree-shaking claim. - Cross-link anchor
/runtime/toml#date-and-time-values-in-bundlesmatches the new###heading slug and follows the existing link convention indocs/. <Note>component and code-fence labels match neighboring usage in both files.
Extended reasoning...
Overview
Two docs files touched: docs/runtime/toml.mdx gains a new ### Date and time values in bundles subsection under Bundler Integration (a TOML+JS example plus three workarounds for runtimes without Temporal), and docs/bundler/loaders.mdx gains a three-line <Note> in the toml loader entry linking to it. No source, test, or config changes.
Security risks
None. Pure prose and fenced code examples in .mdx files; nothing is executed or exposed.
Level of scrutiny
Low. Docs-only, ~25 net lines. I spot-checked the technical claims against the parser: parse_entry.rs:297 sets lower_toml_datetimes purely from the loader (confirming "for every target"), and lower_one_date_time_literal builds Temporal.<class>.from(str) with can_be_unwrapped_if_unused = IfUnused, which is what the printer renders as /* @__PURE__ */ — so the emitted-output snippet and the named-import tree-shaking workaround are both accurate. The Node.js version statement (24 and earlier lack Temporal by default) is correct.
Other factors
CI (Build #98335) is green, prettier passes per the PR description, no CODEOWNERS covers docs/, and there are no prior human review comments to address. The cross-link path style (/runtime/toml#anchor) matches other internal links in the docs tree. The <Note> component is already used a few lines above in the same file for the jsonc loader, so the MDX is consistent.
Problem
Temporal.<Class>.from("...")calls inbun buildoutput. The emit does not depend ontarget(lower_toml_datetimesis set from the loader alone insrc/js_parser/parse/parse_entry.rs).--target=nodeor--target=browserfrom a TOML file containing a date therefore throwsReferenceError: Temporal is not definedat load on a runtime withoutTemporal(Node.js 24 and earlier, for example).docs/runtime/toml.mdx(Bundler Integration) nor thetomlentry indocs/bundler/loaders.mdxmentioned this; the runtime docs only describe theBun.TOML.parse/ import mapping.Fix
docs/runtime/toml.mdx: new "Date and time values in bundles" section under Bundler Integration showing the emitted code and the three ways to run such a bundle on a runtime withoutTemporal(named imports so the date keys tree-shake, quoting the value, or importing a module that installs a globalTemporalahead of the TOML file).docs/bundler/loaders.mdx: one note in thetomlloader entry linking to that section.88a6398836):bun build app.ts --target=browserand--target=nodeboth emitreleased: /* @__PURE__ */ Temporal.PlainDate.from("2026-08-15")forreleased = 2026-08-15.node out.js(Node 26, Temporal enabled) prints the date;node --no-harmony-temporal out.jsthrowsReferenceError: Temporal is not defined.import { name } from "./config.toml"bundles tovar name = "my-app";with noTemporalreference.globalThis.Temporal, imported before the TOML file, precedes the TOML module in the bundle and the bundle runs undernode --no-harmony-temporal.prettier --checkpasses on both files.Background
.tomlfile into a JS module whose exports are the parsed document. At runtime (import/Bun.TOML.parse) date/time values are built as Temporal objects directly. In the bundler the same values have to be expressed as JavaScript source, so the parser rewrites each tagged date/time string into a call on theTemporalglobal; that call runs when the bundle's module-scope code evaluates, which is why the consuming runtime needsTemporal.Temporalby default as of 1.4, so this only matters for bundles run elsewhere. The parser rewrite itself (Rewrite the TOML parser for v1.1.0 conformance #32953) and the integer range rule are already documented on the same page and in the 1.4 upgrade guide (docs: add Bun 1.3 to 1.4 upgrade guide #36463); this PR only fills the bundler gap.no test proof · iteration 0 · docs-only change; test-proof not applicable