File tree 5 files changed +7
-4
lines changed
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 {
178
178
} else {
179
179
let curIndex = 0
180
180
let match : RegExpExecArray | null
181
+ fileRE . lastIndex = 0
181
182
while ( ( match = fileRE . exec ( text ) ) ) {
182
183
const { 0 : file , index } = match
183
184
if ( index != null ) {
Original file line number Diff line number Diff line change @@ -534,11 +534,8 @@ function extractImportPaths(code: string) {
534
534
535
535
let js = ''
536
536
let m
537
+ importsRE . lastIndex = 0
537
538
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
- }
542
539
js += `\nimport ${ m [ 1 ] } `
543
540
}
544
541
return js
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ export function renderAssetUrlInJS(
72
72
73
73
// In both cases, the wrapping should already be fine
74
74
75
+ assetUrlRE . lastIndex = 0
75
76
while ( ( match = assetUrlRE . exec ( code ) ) ) {
76
77
s ||= new MagicString ( code )
77
78
const [ full , referenceId , postfix = '' ] = match
@@ -96,6 +97,7 @@ export function renderAssetUrlInJS(
96
97
// Replace __VITE_PUBLIC_ASSET__5aa0ddc0__ with absolute paths
97
98
98
99
const publicAssetUrlMap = publicAssetUrlCache . get ( config ) !
100
+ publicAssetUrlRE . lastIndex = 0
99
101
while ( ( match = publicAssetUrlRE . exec ( code ) ) ) {
100
102
s ||= new MagicString ( code )
101
103
const [ full , hash ] = match
Original file line number Diff line number Diff line change @@ -398,6 +398,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
398
398
const cleanCode = stripLiteral ( scriptNode . value )
399
399
400
400
let match : RegExpExecArray | null
401
+ inlineImportRE . lastIndex = 0
401
402
while ( ( match = inlineImportRE . exec ( cleanCode ) ) ) {
402
403
const { 1 : url , index } = match
403
404
const startUrl = cleanCode . indexOf ( url , index )
@@ -779,6 +780,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
779
780
// no use assets plugin because it will emit file
780
781
let match : RegExpExecArray | null
781
782
let s : MagicString | undefined
783
+ inlineCSSRE . lastIndex = 0
782
784
while ( ( match = inlineCSSRE . exec ( result ) ) ) {
783
785
s ||= new MagicString ( result )
784
786
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 {
336
336
337
337
let match : RegExpExecArray | null
338
338
s = new MagicString ( code )
339
+ workerAssetUrlRE . lastIndex = 0
339
340
340
341
// Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
341
342
const workerMap = workerCache . get ( config . mainConfig || config ) !
You can’t perform that action at this time.
0 commit comments