vite dev: semi-framework crawl pre-bundles a library's node-only dependencies (@yak/solid > @swc/core) since next.44
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 76/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- node.js, typescript, vite
- Bereich
- build-system, tooling
Rechercherichtung
Start with isSemiFrameworkPkgByJson, crawlFrameworkPkgs, pkgNeedsOptimization, and solidPkgsConfig.optimizeDeps.include to trace how semi-framework dependencies enter the optimizer. Apply the proposed post-crawl filtering for recorded semi-framework packages, then run the next-yak e2e/bundlers/vite-solid suite under vite dev, including its client, SSR, and HMR cases. Done means the suite passes and @swc/core's native binding is no longer pre-bundled.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Since 3.0.0-next.44 (ssr-inline-solid-consumers), vite dev fails in dependency optimization for an app using @yak/solid (DigitecGalaxus/next-yak):
Error: Error during dependency optimization:
[UNLOADABLE_DEPENDENCY] Could not load ../../node_modules/.pnpm/@[email protected]/node_modules/@swc/core-darwin-arm64/swc.darwin-arm64.node
╭─[ …/@swc/core/binding.js:159:24 ]
159 │ return require('@swc/core-darwin-arm64')
│ ────────────┬───────────
│ ╰───────────── stream did not contain valid UTF-8
Reproduced with next.44 and with next at 08782f2 (what next.45 ships); next.38 is fine. The app is next-yak's e2e/bundlers/vite-solid (client + SSR, plugins: [yak(), solid({ ssr: true })]); vite build is unaffected, only vite dev.
Cause
The new semi-framework classification marks any package with solid-js / @solidjs/web in dependencies or peerDependencies as semi-framework so it is ssr.noExternal (one runtime copy). That is the right call for the package itself, but vitefu's crawl treats a semi-framework package like a framework package for its dependencies too: every CJS dependency of it is pushed into optimizeDeps.include as "<pkg> > <dep>" (crawlFrameworkPkgs → pkgNeedsOptimization).
@yak/solid declares solid-js as a peer (semi-framework) and, because its Vite plugin ships in the same package (@yak/solid/vite), lists @swc/core, @babel/parser and yak-swc under dependencies. So @yak/solid > @swc/core lands in the browser optimizer's include list, and rolldown tries to bundle a native .node binding.
Any Solid library that ships a build-time half in the same package (a Vite/Babel plugin, a CLI, a server adapter with node-only deps) hits this the moment it is on next.44+ under vite dev. A framework package (one with a solid export condition) has always had this behaviour from vitefu, but the semi-framework rule extends it to every peer-dependent library, which is a much wider net.
Suggested fix
A semi-framework package is inlined so it shares the runtime; nothing about that needs its own dependencies pre-bundled. Record the semi-framework package names in isSemiFrameworkPkgByJson and drop their entries from solidPkgsConfig.optimizeDeps.include:
const semiFrameworkPkgs = new Set<string>();
// …
isSemiFrameworkPkgByJson(pkgJson) {
if (!(replaceDev || observe) || isTestMode) return false;
const semi = SOLID_RUNTIME_PKGS.some(
(name) => pkgJson.dependencies?.[name] || pkgJson.peerDependencies?.[name],
);
if (semi && pkgJson.name) semiFrameworkPkgs.add(pkgJson.name);
return semi;
},
// …after crawlFrameworkPkgs:
solidPkgsConfig.optimizeDeps.include = solidPkgsConfig.optimizeDeps.include.filter(
(entry) => !semiFrameworkPkgs.has(entry.split(' > ')[0]),
);
With that patch applied to next (built locally), next-yak's full vite-solid e2e passes under vite dev with Solid 2.0.0-rc.10 (36 cases + 7 HMR cases, both fold modes). A browser-side CJS dep of such a package would then be discovered and optimized on first use by Vite instead of up front — a reload in dev at worst, against a hard failure today.
The alternative — not crawling semi-framework packages' deps at all — is not something vitefu's crawlFrameworkPkgs options offer (isSemiFrameworkPkgByJson always recurses), so the post-filter is the smallest change.
Context
Found while preparing DigitecGalaxus/next-yak's move to solid-js 2.0.0-rc.10 (DigitecGalaxus/next-yak#658 and its follow-up). That PR keeps @solidjs/vite-plugin pinned at 3.0.0-next.38 because of this; next.45 also fixes the componentNames → sourceNames option rename the rc.10 compiler needs, so once this lands they can move to one release that works.
— Claude via Cursor
- Vorherrschende Sprache
- TypeScript
- Sterne
- 522
- Forks
- 72
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 38
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus solidjs/solid-vite-plugin
-
Test environment detection doesn't consider Vitest workspacesEvtl. vergeben @carloitaben hat das vor 51 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
solidjs/solid-vite-plugin#205 · 1 Kommentar · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
solidjs/solid-vite-plugin#369 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
solidjs/solid-vite-plugin#328 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Retain $ServerOnly templates while HMR is activeEvtl. vergeben @brenelz hat das vor 24 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
solidjs/solid-vite-plugin#308 ·
Maintainer antworten meist innerhalb von 1 Tag
-
jsx: 'preserve' in optimizeDeps breaks dependency scan when .tsx files use `import.meta.glob`Evtl. vergeben @brenelz hat das vor 24 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
solidjs/solid-vite-plugin#262 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in solidjs/solid-vite-plugin
Ähnliche Issues
-
status: needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
a2ui-project/a2ui#3158 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
hemilabs/ui-monorepo#2475 ·
Maintainer antworten meist innerhalb von 1 Tag
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
lingdojo/kana-dojo#32279 · 1 Kommentar · 5 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
code-quality refactoring
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
github/gh-aw-firewall#9879 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: Arrow-key cursor movement in combined diff view doesn't scroll to keep the cursor visibleOffenos:macos
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag