JSON

JSON is a first-class citizen with Rspack. You can import it directly, for example:

Default import

example.json
{
  "foo": "bar"
}
index.js
import json from './example.json';
console.log(json.foo); // "bar"

Named import

In non-.mjs non-strict ESM files, you can directly import properties from JSON.

example.json
{
  "foo": "bar"
}
index.js
import { foo } from './example.json';
console.log(foo); // "bar"