Skip to content

🔧 A CLI tool batch converts files containing jsx syntax to .jsx

License

Notifications You must be signed in to change notification settings

jaw52/transform-jsx-for-vite

Repository files navigation

transform-jsx-for-vite

npm

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)

Quick Start

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

Instructions for use

Scan path

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

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)。

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

Ignore path

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/**

Modify concurrency

Concurrent number of modification commands executed at the same time (default 5)

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

vitejs/vite#3448

vitejs/vite#3112

About

🔧 A CLI tool batch converts files containing jsx syntax to .jsx

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published