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

Update docs regarding SPA Template ssr.noExternal setting #8957

Merged
merged 2 commits into from Mar 4, 2024

Conversation

brophdawg11
Copy link
Contributor

Follow up to #8952

Copy link

changeset-bot bot commented Mar 1, 2024

⚠️ No Changeset found

Latest commit: bf62380

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -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.
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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
Copy link
Contributor Author

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

@brophdawg11 brophdawg11 merged commit 775d773 into main Mar 4, 2024
2 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/spa-external-docs branch March 4, 2024 16:34
IgnusG pushed a commit to IgnusG/remix that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants