Translations: 简体中文
Batch modify .js
files containing jsx syntax in traditional React projects to .jsx
- ⚡️
.ts
=>.tsx
,.js
=>.jsx
- 💡Using
babel
recognition, high accuracy(in precise mode)
Execute the following command under the root directory of the project to be converted
npx @jaw52/transform-jsx-for-vite
Follow the prompts and wait for batch modification of .js
suffix
If the directory name to be scanned is not src, you can use the relative path to specify it
# relative path
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
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)。 -
Fast mode: fast, but less understanding of jsx syntax than
Babel
(but can also cover a large part)
Manually ignore the scanning of some paths. Refer to fast-glob for rules
# single path
npx @jaw52/transform-jsx-for-vite --ignore **/example/**
# Multiple paths
npx @jaw52/transform-jsx-for-vite --ignore **/.git/** --ignore **/example/**
# Or use commas(Recommended)
npx @jaw52/transform-jsx-for-vite --ignore **/.git/**,**/example/**
Concurrent number of modification commands executed at the same time (default 5)
npx @jaw52/transform-jsx-for-vite --concurrency 10
Vite
does not support .js
files with jsx
syntax in React projects