Vite 8, is it possible to use rolldown's experimental native magic string somehow? #21976
-
|
https://rolldown.rs/in-depth/native-magic-string I tested it out and saw that Vite does not have a experimental.nativeMagicString field. rolldownOptions.experimental.nativeMagicString does exist according to types but setting it doesn't seem to do anything rolldownOptions: {
experimental: {
nativeMagicString: true
},
plugins: [
{
name: "test-magic-string",
transform(code, id, meta) {
console.log("code meta", meta);
// meta is always { moduleType: "js", ssr: "false" } when I test
return null;
}
}
]
}But the meta argument never contains a magicString field. I was unsure if I should open an issue for this since I don't know if the experimental rolldown features are supposed to be usable or not through Vite. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The Looking at the Rolldown docs you linked, the native MagicString feature is about performance optimization for Rolldown's built-in transforms (like module wrapping, tree-shaking, etc.) by using a Rust-backed MagicString instead of the JS one. It's not designed to surface in the The So to answer your question directly: no, you can't currently access Rolldown's native MagicString through Vite plugins. The experimental flag does something, but it affects internal Rolldown performance, not plugin behavior. If you're looking to use a performant string manipulation tool in your own plugin transforms, your best bet is to use the regular |
Beta Was this translation helpful? Give feedback.
The
rolldownOptions.experimental.nativeMagicStringsetting controls whether Rolldown's internal transforms pass a native MagicString instance to its own processing pipeline — it doesn't expose MagicString objects to plugin hooks.Looking at the Rolldown docs you linked, the native MagicString feature is about performance optimization for Rolldown's built-in transforms (like module wrapping, tree-shaking, etc.) by using a Rust-backed MagicString instead of the JS one. It's not designed to surface in the
metaargument of plugintransformhooks.The
metaobject in plugin hooks only containsmoduleTypeandssrbecause those are the metadata fields Vite/Rolldown exposes to plugins. The native …