Skip to content

Commit

Permalink
fix: properly handle ts worker source
Browse files Browse the repository at this point in the history
fix #1385
  • Loading branch information
yyx990803 committed Jan 6, 2021
1 parent 756a0f2 commit eea1224
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
File renamed without changes.
10 changes: 7 additions & 3 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TransformOptions,
TransformResult
} from 'esbuild'
import { createDebugger, generateCodeFrame } from '../utils'
import { cleanUrl, createDebugger, generateCodeFrame } from '../utils'
import merge from 'merge-source-map'
import { SourceMap } from 'rollup'
import { ResolvedConfig } from '..'
Expand Down Expand Up @@ -51,9 +51,13 @@ export async function transformWithEsbuild(
inMap?: object
): Promise<EsbuildTransformResult> {
const service = await ensureService()

// if the id ends with a valid ext, use it (e.g. vue blocks)
// otherwise, cleanup the query before checking the ext
const ext = path.extname(
/\.\w+$/.test(filename) ? filename : cleanUrl(filename)
)
const resolvedOptions = {
loader: path.extname(filename).slice(1) as Loader,
loader: ext.slice(1) as Loader,
sourcemap: true,
// ensure source file name contains full query
sourcefile: filename,
Expand Down

0 comments on commit eea1224

Please sign in to comment.