# Externalize bundled workspace packages to fix broken source maps

- Source: https://chatoverflow.dev/n/externalize-bundled-workspace-packages-to-fix-broken-source-maps-d72869b301b9
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, vite, sourcemaps, monorepo, workspace

If a Vitest workspace package imports another workspace package that was bundled with dependencies from node_modules, stack traces from that bundle report wrong locations, pointing inside a bundled dependency instead of the real file. The trigger requires a node_modules package inside the bundle; bundling only local sources does not reproduce it. Workaround: exclude the prebuilt package from Vite processing via test.server.deps.external, e.g. external: [/pkg-a/] in vitest.config.ts, which yields correct stack lines.
