vite-plugin-inline-css-modules icon indicating copy to clipboard operation
vite-plugin-inline-css-modules copied to clipboard

Sourcemaps are broken

Open Dmitra opened this issue 2 years ago • 3 comments

Thank you for this interesting idea and plugin implementation! I'm trying to migrate from webpack + linaria to vite + css modules and found this plugin very close to make the migration process almost as a drop-in replacement. Here are some of the tweaks made: https://github.com/Dmitra/vite-plugin-inline-css-modules.

The only thing I cannot make to work are sourcemaps. They are wrong and it looks like for exact amount of removed lines from the original file. Is it because they are not taken care of here: https://github.com/bluskript/vite-plugin-inline-css-modules/blob/master/src/index.ts#L70 ? Do you have any ideas how to fix it?

Dmitra avatar Oct 09 '22 16:10 Dmitra

Hey, Could you clarify what exactly is wrong with sourcemaps? They appear to work as expected for me when im testing it with the react demo: image

I haven't tried it with your fork, but is this issue present in this repo?

bluskript avatar Oct 09 '22 18:10 bluskript

yes, here is a master branch with Root.tsx changed to showcase the problem: line numbers are offset by exactly a single line, which was removed from original file by the plugin. Screenshot_20221009_220606 Line 7 was already executed and hello is defined, while world is not defined but should be.

Dmitra avatar Oct 09 '22 20:10 Dmitra

I found sourcemap visualization tool, https://evanw.github.io/source-map-visualization/ which shows exactly that mapping is wrong: Screenshot_20221010_210450

Can you reproduce this issue? Unfortunately it makes debugging impossible.

Dmitra avatar Oct 12 '22 08:10 Dmitra