Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

Problem

The resolve.external setting for the ssr environment was being unconditionally set in the config hook, which caused conflicts with plugins like @cloudflare/vite-plugin that set noExternal: true. This resulted in the following error:

error when starting dev server:
Error: The following environment options are incompatible with the Cloudflare Vite plugin:
        - "ssr" environment: `resolve.external`: ["@solid-primitives/refs","tiny-invariant",...]
To resolve this issue, avoid setting `resolve.external` in your Cloudflare Worker environments.

Related issue: TanStack/router#5291

Solution

This PR fixes the issue by:

  1. Moving SSR configuration to configEnvironment hook (Vite 6+): The configEnvironment hook runs after the config hook, allowing other plugins to set noExternal: true first in their config hooks.

  2. Respecting noExternal: true: Only sets resolve.external if config.resolve.noExternal !== true, preventing conflicts with plugins that require all dependencies to be bundled.

  3. Maintaining backward compatibility: For Vite 3, 4, and 5, the original behavior is preserved by continuing to set ssr: solidPkgsConfig.ssr in the config hook.

Changes

  • Moved solidPkgsConfig to closure scope to make it accessible in the configEnvironment hook
  • For Vite 6+: Conditionally set resolve.noExternal and resolve.external in the configEnvironment hook only when noExternal !== true
  • For Vite 3, 4, 5: Kept the original behavior unchanged

This ensures compatibility with Cloudflare and other plugins that require full control over the noExternal setting, while maintaining all existing functionality for other use cases.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: node index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>SSR resolve.external is unconditionally applied</issue_title>
<issue_description>right now, the resolve.external setting for the ssr environment is currently unconditionally set here

ssr: solidPkgsConfig.ssr,

when used with e.g. the cloudflare vite plugin, this can cause the issue reported here:

TanStack/router#5291

error when starting dev server:
Error: The following environment options are incompatible with the Cloudflare Vite plugin:
        - "ssr" environment: `resolve.external`: ["@solid-primitives/refs","tiny-invariant","@tanstack/history","@solid-devtools/logger","@tanstack/router-core","tiny-warning","isbot","@tanstack/store"]
To resolve this issue, avoid setting `resolve.external` in your Cloudflare Worker environments.

To resolve this, resolve.external should not be set for the ssr environment if noExternal === true.
For this to work, setting this config must be moved to the configEnvironment hook so that another plugin can set noExternal: true in the config hook which runs prior to the configEnvironment hook.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #232


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: 5620f91

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

Copilot AI and others added 2 commits October 21, 2025 15:36
Co-authored-by: birkskyum <74932975+birkskyum@users.noreply.github.com>
- Move SSR config from config hook to configEnvironment hook for Vite 6+
- Only set resolve.external if noExternal !== true to avoid conflicts
- Maintain backward compatibility with Vite 3, 4, 5

Co-authored-by: birkskyum <74932975+birkskyum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unconditional application of SSR resolve.external setting Fix SSR resolve.external being unconditionally applied in Vite 6+ Oct 21, 2025
Copilot AI requested a review from birkskyum October 21, 2025 15:43
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 21, 2025

Open in StackBlitz

npm i https://pkg.pr.new/vite-plugin-solid@236

commit: 5620f91

@birkskyum birkskyum marked this pull request as ready for review October 21, 2025 16:34
Copy link
Member

@birkskyum birkskyum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the the cloudflare vite plugin
TanStack/router#5567

@birkskyum
Copy link
Member

The solid-start test suite (main branch, with vinxi) pass as well

@birkskyum birkskyum removed their assignment Oct 21, 2025
@birkskyum birkskyum merged commit b19050a into main Oct 21, 2025
4 checks passed
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 this pull request may close these issues.

SSR resolve.external is unconditionally applied

3 participants