pd4d10 / vite-plugin-svgr

Vite plugin to transform SVGs into React components
MIT License
562 stars 54 forks source link

Sourcemaps (+possible implementation) #47

Open OleksandrDemian opened 2 years ago

OleksandrDemian commented 2 years ago

It would be great to add sourcemaps support to this project. I think it should be possible to do it using magic-string (npm link).

The implementation might look like this:

        // ... transform code
        const res = await transformWithEsbuild(componentCode, id, {
          loader: 'jsx',
          ...esbuildOptions,
        })

        return {
          code: res.code,
          map: new MagicString(res.code).generateMap({
            source: id,
          }),
        }
pd4d10 commented 2 years ago

Looks great! Would you like to submit a PR?

OleksandrDemian commented 2 years ago

Yes, I'm not sure if this code actually works, I will run a couple of tests, and in case of success I will open the PR.

CodiBurley commented 1 year ago

Yes, I'm not sure if this code actually works, I will run a couple of tests, and in case of success I will open the PR.

Did you ever test this out?

OleksandrDemian commented 1 year ago

@CodiBurley yes, but it doesn't seem to have any impact