You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📖 Documentation (updates to the documentation or readme)
🐞 Bug fix (a non-breaking change that fixes an issue)
👌 Enhancement (improving an existing functionality like performance)
✨ New feature (a non-breaking change that adds functionality)
⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
Currently, if SSR is enabled during build, the renderer tries to inline styles if process.env.NUXT_INLINE_STYLES is true.
It does not take the current request's ssrContext.noSSR into account.
This leads to an error if SSR is disabled dynamically (e.g. using the x-nuxt-no-ssr header in a server middleware):
[nuxt] [request error] [unhandled] [500] globalThis.__buildAssetsURL is not a function
at ./.output/server/chunks/app/styles.mjs:7:276
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async renderInlineStyles (./.output/server/chunks/handlers/renderer.mjs:453:20)
at async ./.output/server/chunks/handlers/renderer.mjs:386:25
at async ./.output/server/chunks/handlers/renderer.mjs:30:22
at async ./.output/server/node_modules/h3/dist/index.mjs:592:19
at async Server.nodeHandler (./.output/server/node_modules/h3/dist/index.mjs:538:7)
My change here disables style inlining if ssrContext.noSSR is true.
Ideally we would still render global inline styles with ssr: false. At the moment, the way we import asset URLs is with globalThis.__buildAssetsURL which is set here:
Ideally we would still render global inline styles with ssr: false.
Wouldn't style inlining for SPA be a completely new feature? From what I understand, inlineSSRStyles is currently always false if the app is built without SSR enabled. This PR only addresses the issue that happens when the app is built with SSR enabled but then disabled during runtime.
danielroe
changed the title
fix(nuxt): no inline styles for client side rendering
fix(nuxt): don't inline styles for per-request ssr: falseOct 12, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
resolves nuxt/nuxt#15124
#7580
❓ Type of change
📚 Description
Currently, if SSR is enabled during build, the renderer tries to inline styles if
process.env.NUXT_INLINE_STYLESis true.It does not take the current request's
ssrContext.noSSRinto account.This leads to an error if SSR is disabled dynamically (e.g. using the
x-nuxt-no-ssrheader in a server middleware):My change here disables style inlining if
ssrContext.noSSRistrue.Resolves nuxt/nuxt#15124 and #7580 .
📝 Checklist