Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw52 committed Mar 16, 2023
1 parent cbf3b2c commit dc997f3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
27 changes: 20 additions & 7 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

[![npm](https://img.shields.io/npm/v/@jaw52/transform-jsx-for-vite)](https://npmjs.com/package/@jaw52/transform-jsx-for-vite)

> This tool is used to assist the traditional React project to VITE support
This tool helps migrate traditional React projects to Vite,Used in batches to modify `.js` file suffix names (**only modify** files containing` jsx` grammar)
Batch modify `.js` files containing jsx syntax in traditional React projects to `.jsx`

- ⚡️`.ts`=>`.tsx`,`.js`=>`.jsx`
- 💡Using `babel` recognition, high accuracy
- 💡Using `babel` recognition, high accuracy(in precise mode)

## Quick Start

Expand All @@ -17,9 +15,9 @@ Execute the following command under the root directory of the project to be conv
npx @jaw52/transform-jsx-for-vite
```

Wait for batch modification of suffix name of '. js'
Follow the prompts and wait for batch modification of `.js` suffix

## Instructions
## Instructions for use

### Scan path

Expand All @@ -31,6 +29,13 @@ Please specify the folder to be scanned ./example/src
Please specify the folder to be scanned example/src
Please specify the folder to be scanned ../example/src
```
### Identification mode selection

Used to identify whether the file contains `jsx`

- Precise mode: Use `Babel` to identify, which is more accurate and time-consuming. There may be a Babel recognition error, resulting in some files not converting the suffix (if this is the case, please provide [issue](https://github.com/jaw52/transform-jsx-for-vite/issues))。

- Fast mode: fast, but less understanding of jsx syntax than `Babel` (but can also cover a large part)

### Ignore path

Expand All @@ -51,4 +56,12 @@ Concurrent number of modification commands executed at the same time (default 5)

```bash
npx @jaw52/transform-jsx-for-vite --concurrency 10
```
```

## Why this library was created

`Vite` does not support `.js` files with `jsx` syntax in React projects

https://github.com/vitejs/vite/discussions/3448

https://github.com/vitejs/vite/discussions/3112
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

Translations: <a href="https://github.com/jaw52/transform-jsx-for-vite/blob/main/README-EN.md">English</a>

> 该工具用于辅助将传统react项目迁移至vite支持
该工具辅助迁移传统React项目到Vite中,用于批量修改`.js`文件后缀名(**只修改**`jsx`语法的文件)。
将传统React项目中含jsx语法的`.js`文件批量修改为`.jsx`

- ⚡️`.ts`=>`.tsx`,`.js`=>`.jsx`
- 💡使用`babel`识别,准确率高
- 💡使用`babel`识别,准确率高(准确模式下)

## 快速开始

Expand All @@ -19,9 +17,9 @@ Translations: <a href="https://github.com/jaw52/transform-jsx-for-vite/blob/main
npx @jaw52/transform-jsx-for-vite
```

等待批量修改`.js`的后缀名
按提示操作,并等待批量修改`.js`的后缀名

## 使用
## 使用说明

### 扫描路径

Expand All @@ -34,6 +32,14 @@ npx @jaw52/transform-jsx-for-vite
请指定需要扫描的文件夹 ../example/src
```

### 识别模式选择

用于识别文件中是否含`jsx`

- 准确模式:使用`Babel`识别,更加准确,耗时一些。可能出现Babel识别错误,导致部分文件未转换后缀名(有这种情况,请提[issue](https://github.com/jaw52/transform-jsx-for-vite/issues))。

- 快速模式:速度快,但对jsx语法的识别程度不如`Babel`(但也能覆盖很大部分)。

### 忽略路径

手动忽略某些路径的扫描,规则参照[fast-glob](https://github.com/mrmlnc/fast-glob#readme)
Expand All @@ -53,4 +59,12 @@ npx @jaw52/transform-jsx-for-vite --ignore **/.git/**,**/example/**

```bash
npx @jaw52/transform-jsx-for-vite --concurrency 10
```
```

## 为什么创建这个库

`Vite`不支持React项目中含`jsx`语法的`.js`文件

https://github.com/vitejs/vite/discussions/3448

https://github.com/vitejs/vite/discussions/3112

0 comments on commit dc997f3

Please sign in to comment.