Skip to content

Commit 334863a

Browse files
committed
fix(test): resolve vendor-aliases paths from package root, not distRoot (#985)
The vendorMap in the vendor-aliases plugin was resolving @vitest/* paths relative to distRoot (dist/@vitest/browser/), producing doubled paths like dist/@vitest/browser/@vitest/browser/context.js. Use packageRoot (dist/) instead, fixing resolution for third-party imports like @storybook/addon-vitest. - Close #963 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: a one-line change in the test build-time patcher that only affects how `@vitest/*` alias paths are resolved in the injected browser plugin. > > **Overview** > Fixes the injected `vitest:vendor-aliases` plugin so its `@vitest/*` alias map resolves files from the dist *package root* (`packageRoot`/`dist/`) instead of `distRoot` (`dist/@vitest/browser/`). > > This prevents incorrect doubled paths when third-party tools import `@vitest/*` modules in browser mode. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 33c6164. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 8f8bcce commit 334863a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/test/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ async function patchVitestBrowserPackage() {
14591459
// This allows imports like @vitest/runner to be resolved to our copied @vitest files
14601460
const mappingEntries = Object.entries(VITEST_PACKAGE_TO_PATH)
14611461
.filter(([pkg]) => pkg.startsWith('@vitest/'))
1462-
.map(([pkg, file]) => `'${pkg}': resolve(distRoot, '${file}')`)
1462+
.map(([pkg, file]) => `'${pkg}': resolve(packageRoot, '${file}')`)
14631463
.join(',\n ');
14641464

14651465
// distRoot is @vitest/browser/ so we need to go up two levels to reach the actual dist root

0 commit comments

Comments
 (0)