Skip to content

Commit

Permalink
fix(import-analysis): improve error for jsx to not be preserve in tsc…
Browse files Browse the repository at this point in the history
…onfig (#12018)
  • Loading branch information
SyMind committed Feb 22, 2023
1 parent 4159e6f commit 91fac1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -197,12 +197,15 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
;[imports, exports] = parseImports(source)
} catch (e: any) {
const isVue = importer.endsWith('.vue')
const isJsx = importer.endsWith('.jsx') || importer.endsWith('.tsx')
const maybeJSX = !isVue && isJSRequest(importer)

const msg = isVue
? `Install @vitejs/plugin-vue to handle .vue files.`
: maybeJSX
? `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
? isJsx
? `If you use tsconfig.json, make sure to not set jsx to preserve.`
: `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
: `You may need to install appropriate plugins to handle the ${path.extname(
importer,
)} file format, or if it's an asset, add "**/*${path.extname(
Expand Down

0 comments on commit 91fac1c

Please sign in to comment.