fix: inline packages that consume the Solid runtime in dev - #352
Conversation
🦋 Changeset detectedLatest commit: 4453614 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: |
bdf2b24 to
02207d9
Compare
Follow-up to a810d09. Inlining solid-js and @solidjs/web fixes every resolution those two perform, and vitefu inlines packages advertising a `solid` export condition. A package that does neither is still external, so Node resolves its own `import "solid-js"` without `development` and loads the production server build while the inlined graph holds the dev one — the same two-instance split, one layer out. @solidjs/meta is the first-party case: no `solid` export condition, so an app rendering <Title> still fails in useContext under solid-js 2.0.0-rc.7 with the core packages already inlined. Classify any package declaring solid-js or @solidjs/web in dependencies or peerDependencies as a semi-framework package: ssr.noExternal without optimizeDeps.exclude, which is right here as they carry no raw Solid components. Gated on replaceDev, so builds are unchanged.
Two guards on the semi-framework rule from the previous commit, plus its test-mode gate: - Tooling skip-list (`isFrameworkPkgByName`): `@solidjs/vite-plugin`, `vite`, `vitest`, `eslint-plugin-*`, `vite-plugin-*`, `prettier-plugin-*`, `@types/*`. These declare solid-js as a peer but never run inside the SSR module runner; classifying the plugin itself as semi-framework made vitefu crawl ITS dependencies and deep-include `@solidjs/vite-plugin > @babel/core` / `> @solidjs/babel-plugin` in the CLIENT optimizeDeps (node_modules/.vite/deps 1.5 MB -> 8.3 MB on the fullstack template). Mirrors vite-plugin-svelte's isCommonDepWithoutSvelteField list. - Never re-externalize an inlined core: vitefu pushes the non-framework `dependencies` of every framework package to `ssr.external` in dev, and Vite checks `external` before `noExternal`. @tanstack/solid-router lists `@solidjs/web` under `dependencies`, so a810d09's noExternal for it was defeated and the tanstack template 500'd with "lazy() called but no asset manifest is set". Filter `ssr.external` against the final noExternal list in configEnvironment. - Gate isSemiFrameworkPkgByJson on !isTestMode as well, matching the core inlining in configEnvironment (vitest manages inlining via test.server.deps). Verified on the fullstack (@solidjs/meta) and fullstack-tanstack templates: both 200 under `vite dev` with a single solid-js/@solidjs/web instance, and the client optimizer output back to its next.40 size. Co-authored-by: Cursor <cursoragent@cursor.com>
02207d9 to
4453614
Compare
|
Rebased onto Verified on the fullstack (
Changeset extended to mention both guards. Both templates 200 with a single |
Follow-up to a810d09 (#350), rebased onto it. That commit fixes the split for
solid-jsand@solidjs/web; this closes the remaining half.The gap
a810d09 reasons:
@solidjs/metadeclares nosolidexport condition:So it stays external, Node resolves its own
import "solid-js"without thedevelopmentcondition, and it loads the production server build while theinlined graph holds the dev one — the same two
sharedConfigs, one layer out.On
3.0.0-next.40an app that renders a<Title>still dies:It generalises past first-party packages: any component library or helper that
imports
solid-jswithout advertising asolidcondition splits the runtimethe same way.
The change
vitefu's semi-framework class is the right bucket —
ssr.noExternalwithoutoptimizeDeps.exclude, since these carry no raw Solid components:Gated on
replaceDev, so builds are unchanged. It composes with a810d09 ratherthan replacing it: that commit still covers the two core packages directly,
including the case where a consumer is absent.
Verified
A start-mode app (
start+ssr: true, file routes, server functions,@solidjs/meta) on solid-js /@solidjs/web2.0.0-rc.7,@solidjs/router2.0.0-next.21, Vite8.2.2:vite dev3.0.0-next.39lazy() … no asset manifest is set3.0.0-next.40(a810d09)useContextin@solidjs/meta, prod buildnext.40+noExternal: ['@solidjs/meta']by handvite build+vite previewstayed 200 throughout — a build applies nodevelopmentcondition, so nothing splits there. Tested with this branch'sbuilt
dist/esm/index.mjsdropped into that app with nossr.noExternalin itsown config.
pnpm build(rollup +tsc --emitDeclarationOnly) is clean.No regression test added — the suites run examples end to end and I could not
tell where a two-instance assertion belongs.
examples/ssrandexamples/css-matrixwould only catch this with a@solidjs/metadependency inthe fixture; happy to add that if it is the right shape.