Skip to content

Commit

Permalink
fix(plugin-react): fix regex for react imports (#5274)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockwotj authored Oct 12, 2021
1 parent 7674cf2 commit 00b3e4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
const userParserPlugins =
opts.parserPlugins || opts.babel?.parserOpts?.plugins || []

const importReactRE = /(^|\n)import\s+(\*\s+as\s+)?React\s+/
// Support pattens like:
// - import * as React from 'react';
// - import React from 'react';
// - import React, {useEffect} from 'react';
const importReactRE = /(^|\n)import\s+(\*\s+as\s+)?React(,|\s+)/

const viteBabel: Plugin = {
name: 'vite:react-babel',
Expand Down

0 comments on commit 00b3e4f

Please sign in to comment.