[Typo]: The alternative way to configure react compiler with vitejs doesn't work

Đang mở
#8,148 1 bình luận 4 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
42/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, react, typescript, vite
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu tại react.dev/learn/react-compiler/installation#vite và so sánh cấu hình Babel thay thế với ví dụ React Router tại #usage-with-react-router. Kiểm tra các trường hợp TypeScript và JavaScript/Vite, sau đó cập nhật trang để setup được tài liệu hóa hoạt động hoặc loại bỏ phương án thay thế; xác nhận rằng các hướng dẫn và ví dụ cuối cùng nhất quán.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

type: typos
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 😅

Ngôn ngữ chính
JavaScript
Star
11.8k
Fork
7.9k
Merge trung bình
16 giờ 6 phút
Pull request đã merge (30 ngày)
7

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của reactjs/react.dev

Tất cả issue của reactjs/react.dev

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.