Skip to content

Commit

Permalink
fix: avoid mutating esbuild options
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 6, 2020
1 parent 906b14c commit bd58858
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/node/esbuildService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ export const transformWithService = async (
file: string,
options: TransformOptions = {}
) => {
options = {
...options,
loader: options.loader || (path.extname(file).slice(1) as any),
sourcemap: true
}
try {
if (!options.loader) {
options.loader = path.extname(file).slice(1) as any
}
options.sourcemap = true
const result = await service.transform(code, options)
if (result.warnings.length) {
console.error(`[vite] warnings while transforming ${file} with esbuild:`)
Expand All @@ -54,6 +55,7 @@ export const transformWithService = async (
}
} catch (e) {
console.error(`[vite] error while transforming ${file} with esbuild:`)
console.error(`options: `, options)
console.error(e)
return {
code: '',
Expand Down

0 comments on commit bd58858

Please sign in to comment.