Skip to content

Commit

Permalink
fix: use proper esbuild loader for .cjs and .mjs files (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
cawa-93 authored Feb 24, 2021
1 parent 58bed16 commit a0d922e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ export async function transformWithEsbuild(
const ext = path.extname(
/\.\w+$/.test(filename) ? filename : cleanUrl(filename)
)

let loader = ext.slice(1)
if (loader === 'cjs' || loader === 'mjs') {
loader = 'js'
}

const resolvedOptions = {
loader: ext.slice(1) as Loader,
loader: loader as Loader,
sourcemap: true,
// ensure source file name contains full query
sourcefile: filename,
Expand Down

0 comments on commit a0d922e

Please sign in to comment.