rollup / rollup

Next-generation ES module bundler
https://rollupjs.org
Other
25.36k stars 1.51k forks source link

Source transform via transform(code, id) and using magic-string returns original sourcemap #5697

Open nikitaosyak opened 2 weeks ago

nikitaosyak commented 2 weeks ago

Hello!

I wanted to make simple source transform, as intended by your library. I do everything like documentation says here:

https://rollupjs.org/plugin-development/#source-code-transformations https://github.com/Rich-Harris/magic-string

using this example, rollup produces sourcemap as it was in the original file (file transform does work though)

some guy on the internet have exactly the same problem (at least had it last year, I guess it's not solved) here: https://stackoverflow.com/questions/77607028/rollup-transform-of-file-including-sourcemap-for-vite

not sure what are my next steps. it's only mildly irritating, but still not something that I would want to have (since why would I even need transform if I cannot also transform sourcemap)

thanks!

nikitaosyak commented 2 weeks ago

rollup plugins from the docs (replace, strip) also demonstrates this behaviour.. I'm starting to think either this is intended, or magic-string just broken, since both those plugins just use magic-string