Skip to content

Commit 1ef31a7

Browse files
feat(vitest): support rolldown-vite in NormalizeUrlPlugin (#7739)
Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
1 parent 7fc5a29 commit 1ef31a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/vitest/src/node/plugins/normalizeURL.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export function NormalizeURLPlugin(): Plugin {
2424

2525
const cleanString = stripLiteral(code)
2626
const assetImportMetaUrlRE
27-
= /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g
27+
// vite injects new URL(path, import.meta.url) in the code
28+
// rolldown-vite injects new URL(path, '' + import.meta.url) in the code
29+
= /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*(?:'' \+ )?import\.meta\.url\s*(?:,\s*)?\)/g
2830

2931
let updatedCode = code
3032
let match: RegExpExecArray | null

0 commit comments

Comments
 (0)