New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix sourcemap when using object as define
value
#15805
fix: fix sourcemap when using object as define
value
#15805
Conversation
Run & review this pull request in StackBlitz Codeflow. |
define
value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Would you resolve the conflicts?
return index === sourceIndex | ||
}), | ||
) | ||
result.map = JSON.stringify(encodedMap(new TraceMap(decoded as any))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't the case before, but now it looks like this is type error. I used as any
for now.
/ecosystem-ci run |
📝 Ran ecosystem CI on ✅ analogjs, astro, histoire, ladle, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, remix, sveltekit, unocss, vike, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest |
Description
I wrote my findings in #15771 (comment). The issue seems to be esbuild including multiple
sources
in source map when it cannot replace "define" value with primitive (esbuild example) while later pipeline for source map collapsing/remapping doesn't expect such extrasources
entries.Since it doesn't look possible to control how esbuild output source entries, I think one way to "fix" this issue is to simply remove all extra source map entries which doesn't correspond to the original source. In this PR, I attempted this approach by using utilities from
@jridgewell/trace-mapping
(which is mostly re-exports of@jridgewell/sourcemap-codec
).todo
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).