Skip to content

Commit

Permalink
fix:use a more appropriate ignoreRegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
moushicheng committed Dec 30, 2022
1 parent a2681c2 commit 35ebf1f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vite/src/node/plugins/esbuild.ts
Expand Up @@ -255,12 +255,10 @@ export function esbuildPlugin(options: ESBuildOptions = {}): Plugin {
async transform(code, id) {
if (filter(id) || filter(cleanUrl(id))) {
let hasViteIgnore = false
if (/\/\* @vite-ignore \*\//.test(code)) {
const ignoreRegExp = /\/\*\s*@vite-ignore\s*\*\/\s*/g
if (ignoreRegExp.test(code)) {
hasViteIgnore = true
code = code.replace(
/\s*\/\* @vite-ignore \*\/\s*/g,
'__vite__ignore__',
)
code = code.replace(ignoreRegExp, '__vite__ignore__')
}
const result = await transformWithEsbuild(code, id, transformOptions)
if (result.warnings.length) {
Expand Down

0 comments on commit 35ebf1f

Please sign in to comment.