question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite plugins (transforms) not run in SSR

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v16.14.0
  • Nuxt Version: 3.0.0-rc.8-27673198.b4bea51
  • Package Manager: yarn@1.22.17
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-cmbd9g

Describe the bug

Seems like Vite transforms are not run in SSR in development mode, leading to a blink on these transforms while developing / booting the server.

Additional context

Not sure about transforms outside of Vue SFCs, but this one specifically occurs in <style> templates of Vue components which might (maybe?) receive a different treatment?

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pi0commented, Aug 13, 2022

/cc @antfu maybe we could introduce some transformInclude presets or utility from unplugin to make it standard?

1reaction
pi0commented, Aug 13, 2022

Regex /\?vue&type=style/ in tranaformInclude was not covering all cases. Some server transform ids look like this:

!! /Users/pooya/tmp/nuxt-starter-cmbd9g/app.vue?direct&vue&type=style&index=0&lang.css                                                      
!! /Users/pooya/tmp/nuxt-starter-cmbd9g/app.vue?direct&vue&type=style&index=1&scoped=938b83b0&lang.css

Simply changing to /vue&type=style/ fixes issue but I would suggest using ufo parser.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-Side Rendering
Dependencies are "externalized" from Vite's SSR transform module system by default when running SSR. This speeds up both dev and build. If a...
Read more >
Can't get @vitejs/plugin-legacy working · Issue #39
I guess it's due to vite-plugin-ssr not using Vites static index.html file. No, the HTML transformers of all plugins are applied.
Read more >
Using vite-plugin-ssr with mdx-js, solving ESM only library ...
The plugin transforms the build files and replaces the import as given as options to the plugin. Now you can run npm run...
Read more >
Dev SSR on Nuxt with Vite
Vite's dev server provides a method called transformRequest() , which is the same as you requesting a module from the browser but in...
Read more >
What About Vite SSR?
Why not put server.js in the product? See the “Production environment doesn't work out of the box” section below. The role of server.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found