Skip to content
Open
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
5 changes: 5 additions & 0 deletions docs/bundler/loaders.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ var config = {
config.logLevel;
```

<Note>
Bun compiles TOML date/time values to `Temporal.*.from()` calls, for every `target`. The runtime that loads the bundle
needs a `Temporal` global. See [Date and time values in bundles](/runtime/toml#date-and-time-values-in-bundles).
</Note>

If you pass a `.toml` file as an entrypoint, Bun converts it to a `.js` module that `export default`s the parsed object.

<CodeGroup>
Expand Down
22 changes: 22 additions & 0 deletions docs/runtime/toml.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,28 @@ This means:
- Smaller bundle sizes
- Tree shaking of unused properties (named imports)

### Date and time values in bundles

Bun compiles each TOML date/time value to a call on the `Temporal` global. The call runs when the bundle loads, for every `target`:

```toml config.toml
name = "my-app"
released = 2026-08-15
```

```js Output
var config_default = {
name: "my-app",
released: /* @__PURE__ */ Temporal.PlainDate.from("2026-08-15"),
};
```

A runtime without `Temporal` throws `ReferenceError: Temporal is not defined` when it loads the bundle. Bun has `Temporal`. Node.js 24 and earlier do not. To run the bundle on a runtime without `Temporal`, do one of the following:

- Import only the keys you use (`import { name } from "./config.toml"`). Bun tree-shakes the unused keys, including the date/time values.
- Quote the value in the TOML file (`released = "2026-08-15"`) so Bun emits a string.
- Import a module that defines `globalThis.Temporal`, such as a Temporal polyfill, before the TOML file. Bun keeps the import order, so the polyfill runs before the date/time calls.

### Dynamic Imports

You can also dynamically import TOML files:
Expand Down