Skip to content

Commit

Permalink
fix(dev): strip utf-8 bom (vitejs#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed Apr 27, 2021
1 parent 82dc588 commit 182795d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -112,6 +112,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
const rewriteStart = Date.now()
await init
let imports: readonly ImportSpecifier[] = []
// strip UTF-8 BOM
if (source.charCodeAt(0) === 0xfeff) {
source = source.slice(1)
}
try {
imports = parseImports(source)[0]
} catch (e) {
Expand Down

0 comments on commit 182795d

Please sign in to comment.