From bd588584231cd41fb016811cf22f76d0ffa13c72 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 6 May 2020 14:57:13 -0400 Subject: [PATCH] fix: avoid mutating esbuild options --- src/node/esbuildService.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/node/esbuildService.ts b/src/node/esbuildService.ts index e18c712219e98c..6e366161239103 100644 --- a/src/node/esbuildService.ts +++ b/src/node/esbuildService.ts @@ -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:`) @@ -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: '',