Skip to content

Commit

Permalink
fix: use transformWithEsBuild()
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts committed Aug 21, 2021
1 parent a88f5b4 commit 3707279
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -15,7 +15,7 @@ import {
import { esbuildDepPlugin } from './esbuildDepPlugin'
import { ImportSpecifier, init, parse } from 'es-module-lexer'
import { scanImports } from './scan'
import { transform } from 'esbuild'
import { transformWithEsbuild } from '../plugins/esbuild'

const debug = createDebugger('vite:deps')

Expand Down Expand Up @@ -244,16 +244,16 @@ export async function optimizeDeps(
await init
for (const id in deps) {
const flatId = flattenId(id)
flatIdDeps[flatId] = deps[id]
const entryContent = fs.readFileSync(deps[id], 'utf-8')
const filePath = (flatIdDeps[flatId] = deps[id])
const entryContent = fs.readFileSync(filePath, 'utf-8')
let exportsData: ExportsData
try {
exportsData = parse(entryContent) as ExportsData
} catch {
debug(
`Unable to parse dependency: ${id}. Trying again with a JSX transform.`
)
const transformed = await transform(entryContent, {
const transformed = await transformWithEsbuild(entryContent, filePath, {
loader: 'jsx'
})
// Ensure that optimization won't fail.
Expand Down

0 comments on commit 3707279

Please sign in to comment.