| Crates.io | rolldown_plugin_json |
| lib.rs | rolldown_plugin_json |
| version | 0.1.0 |
| created_at | 2025-10-18 03:35:51.626239+00 |
| updated_at | 2025-10-18 03:35:51.626239+00 |
| description | Rolldown plugin for JSON file imports |
| homepage | https://rolldown.rs/ |
| repository | https://github.com/rolldown/rolldown |
| max_upload_size | |
| id | 1888765 |
| size | 85,203 |
A plugin for rolldown-vite that handles the transformation of JSON files into JavaScript modules, ported from Vite's jsonPlugin.
This plugin is exclusive to rolldown-vite and is not recommended for external use.
This plugin processes JSON files and transforms them into JavaScript modules. The resulting JavaScript either directly exports the parsed JSON or provides a wrapper around JSON.parse() depending on the configuration.
import { defineConfig } from 'rolldown';
import { jsonPlugin } from 'rolldown/experimental';
export default defineConfig({
input: {
entry: './main.ts',
},
plugins: [jsonPlugin({
minify: false,
namedExports: false,
stringify: 'auto',
})],
});
| Option | Type | Description | Default |
|---|---|---|---|
minify |
boolean |
Whether to minify the JSON content (remove spaces and formatting) for stringify. |
false |
namedExports |
boolean |
Whether to use named exports for JSON properties (useful for ESM compatibility). | false |
stringify |
JsonPluginStringify |
Determines when the JSON content should be stringified into a JSON.parse() call. |
"auto" |
JsonPluginStringifyThis option controls how the JSON content is processed:
"auto": Automatically decides whether to stringify the JSON based on file size.true: Always stringify the content, even for small JSON files.false: Never stringify, just export the JSON as is.