Skip to content

Commit

Permalink
fix: add customized loader to debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
dickeylth committed Mar 28, 2022
1 parent f12fd5e commit 6135c38
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -412,11 +412,15 @@ export async function runOptimizeDeps(
try {
exportsData = parse(entryContent) as ExportsData
} catch {
const loader =
(esbuildOptions.loader &&
esbuildOptions.loader[path.extname(filePath)]) ||
'jsx'
debug(
`Unable to parse dependency: ${id}. Trying again with a JSX transform.`
`Unable to parse dependency: ${id}. Trying again with a ${loader} transform.`
)
const transformed = await transformWithEsbuild(entryContent, filePath, {
loader: 'jsx'
loader
})
// Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
// This is useful for packages such as Gatsby.
Expand Down

0 comments on commit 6135c38

Please sign in to comment.