Skip to content

Commit 0df0c5f

Browse files
Brooooooklynclaude
andcommitted
fix(test): throw errors instead of warnings for critical patch failures
Convert warnings to errors for critical patches in patchVitestBrowserPackage: - vendor-aliases plugin injection - exclude list patching - BrowserContext alias patching This ensures build fails immediately if vitest code changes break our patches, rather than producing confusing runtime errors for users. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5ceef52 commit 0df0c5f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

packages/test/build.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,10 @@ async function patchVitestBrowserPackage() {
12031203
content = content.replace(pluginArrayPattern, `$1\n ${vendorAliasesPlugin},$2`);
12041204
console.log(' Injected vitest:vendor-aliases plugin');
12051205
} else {
1206-
console.log(' Warning: Could not find browser plugin array to inject vendor-aliases');
1206+
throw new Error(
1207+
'Failed to inject vendor-aliases plugin in @vitest/browser/index.js: pattern not found. ' +
1208+
'This likely means vitest code has changed and the patch needs to be updated.',
1209+
);
12071210
}
12081211

12091212
// 2. Patch exclude list to add native deps
@@ -1225,7 +1228,10 @@ async function patchVitestBrowserPackage() {
12251228
content = content.replace(excludePattern, excludeReplacement);
12261229
console.log(' Patched exclude list with native deps');
12271230
} else {
1228-
console.log(' Warning: Could not find exclude array to patch');
1231+
throw new Error(
1232+
'Failed to patch exclude list in @vitest/browser/index.js: pattern not found. ' +
1233+
'This likely means vitest code has changed and the patch needs to be updated.',
1234+
);
12291235
}
12301236

12311237
// 3. Remove include patterns that reference bundled deps
@@ -1255,7 +1261,10 @@ async function patchVitestBrowserPackage() {
12551261
);
12561262
console.log(' Patched BrowserContext to handle package aliases');
12571263
} else {
1258-
console.log(' Warning: Could not find BrowserContext pattern to patch');
1264+
throw new Error(
1265+
'Failed to patch BrowserContext in @vitest/browser/index.js: pattern not found. ' +
1266+
'This likely means vitest code has changed and the patch needs to be updated.',
1267+
);
12591268
}
12601269

12611270
await writeFile(browserIndexPath, content, 'utf-8');

0 commit comments

Comments
 (0)