Skip to content
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

Vite: Sourcemap warning suppression #699

Closed
mcclayton opened this issue May 26, 2022 · 5 comments · Fixed by #706
Closed

Vite: Sourcemap warning suppression #699

mcclayton opened this issue May 26, 2022 · 5 comments · Fixed by #706

Comments

@mcclayton
Copy link

mcclayton commented May 26, 2022

Describe the bug

When building an app using vite and vanilla extract, and when the build.sourcemap vite config option is set to true, I receive a bunch of sourcemap warnings.
i.e.

vite v2.9.9 building for production...
✓ 15216 modules transformed.
rendering chunks (2)...Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vanilla-extract) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
...

The vanilla extract docs list a way to supress this warning for esbuild:
https://github.com/seek-oss/vanilla-extract#esbuild

but I haven't found a way to suppress them for Vite. Would love to be able to suppress these if possible.

Link to reproduction

System Info

Output of npx envinfo --system --npmPackages @vanilla-extract/css,@vanilla-extract/webpack-plugin,@vanilla-extract/esbuild-plugin,@vanilla-extract/vite-plugin,@vanilla-extract/sprinkles,webpack,esbuild,vite --binaries --browsers:

  System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 3.75 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.asdf/installs/nodejs/16.13.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.3.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 101.0.4951.64
    Firefox: 100.0.2
    Safari: 15.3
  npmPackages:
    @vanilla-extract/css: ^1.6.8 => 1.6.8
    @vanilla-extract/vite-plugin: ^3.1.6 => 3.1.6
    @vanilla-extract/webpack-plugin: ^2.1.5 => 2.1.10
    vite: ^2.9.9 => 2.9.9
@mcclayton mcclayton changed the title Vite: Sourcemap error suppression Vite: Sourcemap warning suppression May 26, 2022
@roginfarrer
Copy link
Contributor

The rollup plugin generates a similar warning https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect

@mattcompiles
Copy link
Contributor

I'm not sure creating sourcemaps for VE files is possible, as the transform that occurs is not an AST transform. I agree this warning is not ideal though. Not sure what the recommended approach is here. Is there a way to tell Vite/Rollup that this transform won't create a sourcemap and to not warn about it? Or am I wrong about sourcemaps being a viable option?

@graup
Copy link
Collaborator

graup commented May 31, 2022

I think it may be difficult to create exact sourcemaps, but it might be possible to at least provide a mapping to the relevant style()/createSprinkles()/globalStyle()/etc call in the source .css.ts? This would be better than nothing as it helps to find the correct file.

@mattcompiles
Copy link
Contributor

@graup Do you have any ideas on how to implement it?

@graup
Copy link
Collaborator

graup commented May 31, 2022

For now, it should be possible to suppress the warnings by returning empty source maps. Haven't tested it but I think in the transform functions we just need to change

return processVanillaFile(...)

to

return {
  code: await processVanillaFile(...),
  map: { mappings: '' }
}

I'll have a think about if we can return more meaningful maps there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants