fix(vite-node): Generate sourcemap for inlined deps#6041
fix(vite-node): Generate sourcemap for inlined deps#6041bgoscinski wants to merge 1 commit intovitest-dev:mainfrom
Conversation
1668814 to
1a24089
Compare
|
|
||
| const sourcemap = this.options.sourcemap ?? 'inline' | ||
| if (sourcemap === 'inline' && result && !id.includes('node_modules')) { | ||
| if (sourcemap === 'inline' && result && !(await this.shouldExternalize(id))) { |
There was a problem hiding this comment.
This doesn't make much sense because it will alway return true - this function is not called otherwise:
vitest/packages/vite-node/src/server.ts
Lines 347 to 358 in 5131992
We don't inline source map because it's expensive to do for every file in node modules
There was a problem hiding this comment.
Is there a way for me as a vitest user force it to generate source maps for specific modules from node_modules? In my case I'd like to generate source maps for the deps that I inline (server.deps.inline) because of #5605
There was a problem hiding this comment.
No, there is no way to do that, all node_modules files ignore stack trace. Maybe we can add another option 🤷🏻
There was a problem hiding this comment.
A new option in the config would solve my usecase 💯!
If it makes sense to allow users to generate source maps for not necessairly inlined deps then server.deps.sourcemap accepting (string | RegExp)[] seem ok, but if it makes sense only for inline deps then how about extending server.deps.inline like this
-inline: (string | RegExp)[] | true
+inline: (string | RegExp)[] | true | { match: string | RegExp, sourcemap: boolean }[]There was a problem hiding this comment.
Adding an object to inline would be a breaking change, so if you want it to be fixed that way we will need to wait until Vitest 3. I was thinking about a separate option like includeSourcemap?: string | RegExp[]
There was a problem hiding this comment.
Ok thanks!
I'll close this PR then and see if I'll be able to implement the includeSourcemap option
closes #5605
I implemented the change that allows to use the source maps but I could really use some guidance on if/how you want this tested
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.