Skip to content

Commit c18ce86

Browse files
docs(rolldown): add withFilter + performance chapter (#19890)
1 parent 28603c2 commit c18ce86

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

docs/guide/rolldown.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,39 @@ Rolldown throws an error when unknown or invalid options are passed. Because som
9898
9999
If you don't pass the option in yourself, this must be fixed by the utilized framework. You can suppress this error in the meantime by setting the `ROLLDOWN_OPTIONS_VALIDATION=loose` environment variable.
100100

101-
## Enabling Native Plugins
101+
## Performance
102+
103+
`rolldown-vite` is focused on ensuring compatibility with the existing ecosystem, so defaults are geared towards a smooth transition. You can get further performance gains by switching over to faster Rust-based internal plugins and other customizations.
104+
105+
### Enabling Native Plugins
102106

103107
Thanks to Rolldown and Oxc, various internal Vite plugins, such as the alias or resolve plugin, have been converted to Rust. At the time of writing, using these plugins is not enabled by default, as their behavior may differ from the JavaScript versions.
104108

105109
To test them, you can set the `experimental.enableNativePlugin` option to `true` in your Vite config.
106110

111+
### `withFilter` Wrapper
112+
113+
Plugin authors have the option to use the [hook filter feature](#hook-filter-feature) to reduce the communication overhead between the Rust and JavaScript runtimes.
114+
But in case some of the used plugins are not using this feature (yet) but you still want to benefit from it, you can use the `withFilter` wrapper to wrap the plugin with a filter yourself.
115+
116+
```js
117+
// In your vite.config.ts
118+
import { withFilter, defineConfig } from 'vite'
119+
import svgr from 'vite-plugin-svgr'
120+
121+
export default defineConfig({
122+
plugins: [
123+
// Load the `svgr` plugin only for files which end in `.svg?react`
124+
withFilter(
125+
svgr({
126+
/*...*/
127+
}),
128+
{ load: { id: /\.svg?react$/ } },
129+
),
130+
],
131+
})
132+
```
133+
107134
## Reporting Issues
108135

109136
Since this is an experimental integration, you may encounter issues. If you do, please report them in the [`vitejs/rolldown-vite`](https://github.com/vitejs/rolldown-vite) repository, **not the main Vite repository**.

0 commit comments

Comments
 (0)