File tree Expand file tree Collapse file tree 5 files changed +7
-4
lines changed
Expand file tree Collapse file tree 5 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ export class ErrorOverlay extends HTMLElement {
178178 } else {
179179 let curIndex = 0
180180 let match : RegExpExecArray | null
181+ fileRE . lastIndex = 0
181182 while ( ( match = fileRE . exec ( text ) ) ) {
182183 const { 0 : file , index } = match
183184 if ( index != null ) {
Original file line number Diff line number Diff line change @@ -534,11 +534,8 @@ function extractImportPaths(code: string) {
534534
535535 let js = ''
536536 let m
537+ importsRE . lastIndex = 0
537538 while ( ( m = importsRE . exec ( code ) ) != null ) {
538- // This is necessary to avoid infinite loops with zero-width matches
539- if ( m . index === importsRE . lastIndex ) {
540- importsRE . lastIndex ++
541- }
542539 js += `\nimport ${ m [ 1 ] } `
543540 }
544541 return js
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ export function renderAssetUrlInJS(
7272
7373 // In both cases, the wrapping should already be fine
7474
75+ assetUrlRE . lastIndex = 0
7576 while ( ( match = assetUrlRE . exec ( code ) ) ) {
7677 s ||= new MagicString ( code )
7778 const [ full , referenceId , postfix = '' ] = match
@@ -96,6 +97,7 @@ export function renderAssetUrlInJS(
9697 // Replace __VITE_PUBLIC_ASSET__5aa0ddc0__ with absolute paths
9798
9899 const publicAssetUrlMap = publicAssetUrlCache . get ( config ) !
100+ publicAssetUrlRE . lastIndex = 0
99101 while ( ( match = publicAssetUrlRE . exec ( code ) ) ) {
100102 s ||= new MagicString ( code )
101103 const [ full , hash ] = match
Original file line number Diff line number Diff line change @@ -398,6 +398,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
398398 const cleanCode = stripLiteral ( scriptNode . value )
399399
400400 let match : RegExpExecArray | null
401+ inlineImportRE . lastIndex = 0
401402 while ( ( match = inlineImportRE . exec ( cleanCode ) ) ) {
402403 const { 1 : url , index } = match
403404 const startUrl = cleanCode . indexOf ( url , index )
@@ -779,6 +780,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
779780 // no use assets plugin because it will emit file
780781 let match : RegExpExecArray | null
781782 let s : MagicString | undefined
783+ inlineCSSRE . lastIndex = 0
782784 while ( ( match = inlineCSSRE . exec ( result ) ) ) {
783785 s ||= new MagicString ( result )
784786 const { 0 : full , 1 : scopedName } = match
Original file line number Diff line number Diff line change @@ -336,6 +336,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
336336
337337 let match : RegExpExecArray | null
338338 s = new MagicString ( code )
339+ workerAssetUrlRE . lastIndex = 0
339340
340341 // Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
341342 const workerMap = workerCache . get ( config . mainConfig || config ) !
You can’t perform that action at this time.
0 commit comments