-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Update docs regarding SPA Template ssr.noExternal setting #8957
Conversation
|
docs/future/spa-mode.md
Outdated
@@ -228,8 +228,7 @@ startTransition(() => { | |||
- Generally speaking, the way to resolve these issues is to import any browser-only libraries from `entry.client.tsx` so they don't end up in the server build | |||
- Otherwise, you can generally solve these by using [`React.lazy`][react-lazy] or the [`<ClientOnly>`][client-only] component from `remix-utils` | |||
|
|||
- The [SPA Mode template][spa-mode-template] enables the Vite [ssr.noExternal][vite-ssr-noexternal] option by default to automatically bundle all of your dependencies during the server build to avoid most ESM/CJS issues | |||
- This may slow down your build a bit — if so, you can try removing this option, or switching to a more targeted array containing the specific dependencies you wish to bundle | |||
- If you are running into ESM/CJS issues with your app dependencies you may need to set the Vite [ssr.external][vite-ssr-external] and/or [ssr.noExternal][vite-ssr-noexternal] options in your config to exclude or include certain dependencies in your server bundle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to be more specific that noExternal
will bundle the dependencies in your server bundle. I worry a bit that the language as it stands is going to encourage people to just flip a coin putting dependencies in ssr.external
vs ssr.noExternal
, whereas they really are always going to want to try ssr.noExternal
(unless they set that to true
, but that feels like the unhappy path at this point).
Also might be good to include a quick code snipped, in case they don't realize ssr
is a top level key in the vite config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It's tricky to draw the line between how much we should explain vite stuff that's already documented on the vite pages we're linking too. Bring too much over and our docs get bloated and potentially stale. Bring too little over and folks who don't click through may not grok the point we're making. I'll push an update to try to make this a bit clearer though - and I agree the code snippet would be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -222,14 +222,41 @@ startTransition(() => { | |||
|
|||
- You cannot call `serverLoader`/`serverAction` from your `clientLoader`/`clientAction` methods since there is no running server -- those will throw a runtime error if called | |||
|
|||
- It's important to note that Remix SPA mode generates your `index.html` file by performing a "pre-render" of your root route on the server during the build | |||
### Server Build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the bottom 2 more complex bullet points to sub headings to make them linkable and facilitate a code snippet
Follow up to #8952