[Typo]: The alternative way to configure react compiler with vitejs doesn't work
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- JavaScript
- Estrelas
- 11.8k
- Forks
- 7.9k
- Merge médio
- 1d 11h
- PRs com merge (30d)
- 11
Descrição
Summary
The alternative way to configure react-compiler with Vitejs, which is to declare the Babel configuration separately, doesn't actually work.
Page
https://react.dev/learn/react-compiler/installation#vite
Details
Note that I'm talking about a TypeScript scenario.
I figure this is because of the default filter parameter which is specfieid to be jsx (you can find it here).
For the fix, it seems the babel config provided for react-router case works well with vite-plugin-react. so maybe we can use that, it would look something like this:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import babel from 'vite-plugin-babel';
const ReactCompilerConfig = { /* ... */ };
export default defineConfig({
plugins: [
react(),
babel({
filter: /\.[jt]sx?$/,
babelConfig: {
presets: ["@babel/preset-typescript"],
plugins: [
["babel-plugin-react-compiler", ReactCompilerConfig],
],
},
}),
],
});
Also, maybe it's not a good idea to talk about it here, but I suggest to also have a guide for how the configuration should look like for a vite user who uses JavaScript (jsx) instead of TypeScript because apparently removing the TypeScript babel preset doesn't turn it into a JavaScript configuration; it requires more adjustments.
so maybe considering all of this, we are better off just removing the alternative, since it causes more problems than it solves 😅
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece em react.dev/learn/react-compiler/installation#vite e compare a configuração alternativa do Babel com o exemplo de React Router em #usage-with-react-router. Verifique os casos de TypeScript e JavaScript/Vite e, em seguida, atualize a página para que a configuração documentada funcione ou remova a alternativa; confirme que as instruções e os exemplos finais são consistentes.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript, react, typescript, vite
- Domínio
- documentation
- Tipo de issue
- Documentação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 42/100