-
|
Hello, I had a question about the recommended way to use the logger with the Since Is that the recommended approach, or would it be better to skip the Example config import { defineConfig } from "vite";
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
import babel from "@rolldown/plugin-babel";
import type { Logger } from "babel-plugin-react-compiler";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
babel({
presets: [reactCompilerPreset()],
plugins: [
[
"babel-plugin-react-compiler",
{
logger: {
logEvent(filename, event) {
console.log(filename, event);
},
} satisfies Logger,
},
],
],
}),
],
});Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Looking at the current The tricky part is that the helper currently only accepts
So the answer to “should I use both?” is probably no. If you need This might also be worth an enhancement request: |
Beta Was this translation helpful? Give feedback.
-
|
Yes @clyxudev is correct, this was a type issue on our side that just released in 6.0.2 With this version, this should work and be typesafe: export default defineConfig({
plugins: [
react(),
babel({
presets: [
reactCompilerPreset({
logger: {
logEvent(filename, event) {
console.log(filename, event);
},
},
}),
],
}),
],
}); |
Beta Was this translation helpful? Give feedback.
-
|
Great! Thanks. |
Beta Was this translation helpful? Give feedback.
Looking at the current
reactCompilerPresetimplementation, I would not addbabel-plugin-react-compilera second time next toreactCompilerPreset(). The helper already expands toplugins: [['babel-plugin-react-compiler', options]], so adding the plugin again would very likely run the compiler twice.The tricky part is that the helper currently only accepts
compilationModeandtarget, while it also adds useful Rolldown-specific behavior around filtering, client environments, andoptimizeDeps. So for a logger today I think the clean choices are:reactCompilerPreset()and configurebabel-plugin-react-compilerdirectly withlogger, if you are okay managing the filtering yourself.