fix: keep a semi-framework package's dependencies out of optimizeDeps.include - #376
Merged
Merged
Conversation
….include (#375) Since the semi-framework classification (any package with solid-js or @solidjs/web in dependencies/peerDependencies is ssr.noExternal so it shares the app's runtime copy), vitefu's crawl also deep-included every CJS dependency of such a package into the browser's optimizeDeps.include, as it does for framework packages. For @yak/solid that is @swc/core, and rolldown failed on its native .node binding before vite dev served a page. Sharing the runtime needs nothing pre-bundled. Record the names isSemiFrameworkPkgByJson classifies and drop every include chain that passes through one; a browser-side CJS dependency of such a package is discovered and optimized on first use, as before the package was classified. Framework packages (a solid export condition) keep vitefu's full treatment. Verified against next-yak's vite-solid e2e (client + SSR dev server, 36 cases + 7 HMR cases, both fold modes) on solid-js 2.0.0-rc.10, which fails in dependency optimization on next.44/next.45 and passes with this. Co-authored-by: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 94f1878 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #375.
Problem
Since the semi-framework classification landed in next.44 (
ssr-inline-solid-consumers), any package withsolid-js/@solidjs/webindependenciesorpeerDependenciesisssr.noExternalundervite devso it shares the app's runtime copy. Right call for the package itself — but vitefu'scrawlFrameworkPkgstreats a semi-framework package like a framework package for its dependencies too: every CJS dependency is deep-included as"pkg > dep"in the browser'soptimizeDeps.include.For a library that ships its build-time half in the same package that means node-only modules in the client pre-bundle.
@yak/solidlists@swc/core(its Vite plugin needs it), and rolldown fails on the native.nodebinding before the dev server serves anything:Before next.44 such a package was "unknown" to the crawl: read, found to be neither kind, and not recursed into — its dependencies were never touched.
Fix
Sharing the runtime needs nothing pre-bundled.
isSemiFrameworkPkgByJsonrecords the names it classifies, and after the crawl everyoptimizeDeps.includechain that passes through one of them is dropped. A browser-side CJS dependency of such a package is then discovered and optimized by Vite on first use — the behaviour it had before the package was classified at all. Framework packages (asolidexport condition) keep vitefu's full treatment; that contract is unchanged.vitefu offers no "noExternal without crawling deps" option (
isSemiFrameworkPkgByJsonalways recurses), so the post-filter is the smallest change.Verification
e2e/bundlers/vite-solid(client + SSR dev server,plugins: [yak(), solid({ ssr: true })]) on solid-js 2.0.0-rc.10: fails in dependency optimization with next.44 and withnextat 08782f2; with this branch built and installed via tarball, 36 cases + 7 HMR cases pass in both fold modes.examples/ssr: build andpnpm test(8/8 boundary assertions) pass.pnpm buildclean.Context: DigitecGalaxus/next-yak#659 pins
@solidjs/vite-pluginat next.38 because of this; once this ships they can take next.45+ (which also carries thecomponentNames→sourceNamesrename the rc.10 compiler requires).Co-authored with Claude via Cursor.