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

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
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("https://github.com/vitest-dev/vitest/commit/path,%20import.meta.url") in the code
28+
// rolldown-vite injects new url("https://github.com/vitest-dev/vitest/commit/path,%20''%20+%20import.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)