Vite plugin that enables JSX syntax in .js files by injecting React import and applying Babel transformations, addressing Vite's default limitation to .jsx/.tsx files. Current version 1.0.7 is actively maintained for Vite 2+ and React 17+. Handles React 17+ automatic JSX runtime, supports custom Babel plugins, and mitigates Vite pre-bundling errors via optimizeDeps configuration. Key differentiator: replaces manual .js to .jsx renaming or custom Rollup plugins, with built-in condition-based React injection based on React version detection.
npm install vite-plugin-react-js-supportNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures Vite to support JSX in .js files, injects React import, and disables optimizeDeps to prevent pre-bundling errors.
Set jsxInject to false and manually ensure import React from 'react' in every file, or upgrade React to 17+.
Add optimizeDeps: { entries: false } to Vite config as shown in README.Use either .js or .jsx consistently, or ensure @vitejs/plugin-react is also added to handle .jsx files.
In vite.config.js, set esbuild: { jsx: 'automatic', jsxImportSource: 'react' } and remove this plugin.Ensure custom plugins are designed to run after JSX transform, or use Vite's native Babel integration via @vitejs/plugin-react's babel property.
npm install --save-dev vite-plugin-react-js-support and ensure vite.config.js uses ES module syntax (type: 'module' in package.json or .mjs extension).
Add the plugin to vite.config.js and restart dev server. If error persists, check that optimizeDeps.entries is set to false.
Ensure 'react' is installed and jsxInject: true. For React <17, set jsxInject: true anyway, or manually add import React from 'react' to files.
Remove the plugin and configure esbuild: { jsx: 'automatic' } in vite.config.js.No dependency data recorded yet.