1- import { beforeAll , describe , expect , test } from "vitest" ;
1+ import { afterAll , beforeAll , describe , expect , test } from "vitest" ;
22import { exec , mkdir , rm } from "shelljs" ;
33import { download , extract } from "gitly" ;
4- import { appendFileSync , existsSync , readFileSync , realpathSync , writeFileSync } from "fs" ;
4+ import {
5+ appendFileSync ,
6+ existsSync ,
7+ readFileSync ,
8+ readdirSync ,
9+ realpathSync ,
10+ statSync ,
11+ writeFileSync
12+ } from "fs" ;
513import { join , resolve } from "path" ;
14+ import { spawnSync } from "child_process" ;
615
716/**
817 * Release gate: the TanStack Solid Query adapter's full suite against the
918 * WORKSPACE-BUILT core — solid-js, @solidjs/signals, and @solidjs/web packed
10- * from this tree and installed together, never a registry mix.
19+ * from this tree and installed together, never a registry mix — compiled by
20+ * the WORKSPACE-BUILT compiler (@solidjs/compiler with this tree's native
21+ * binding, @solidjs/babel-plugin), never the registry's.
22+ *
23+ * Both halves matter. Compiled output and runtime are one contract: rc.9
24+ * moved delegated event handlers to the `_$$<type>` key, and against the
25+ * fixture's published compiler (still emitting `$$<type>`) every click in
26+ * the suite was a no-op — 95 failures, none of them adapter semantics, and
27+ * circular: the fixture could not pick up the new compiler until the
28+ * release was on npm, and the gate blocked the release (#3534).
1129 *
1230 * This exists because core-side suites structurally cannot protect the
1331 * adapter contract. The rc.5 regression (#3181's fix waking parked readers
@@ -27,14 +45,35 @@ import { join, resolve } from "path";
2745
2846// The ref the gate tracks — overridable for one-off runs via
2947// SOLID_QUERY_GATE_REPO. The question a release must answer is "does OUR
30- // next core break the adapter people will install alongside it". Today that
31- // adapter lives on the PR branch carrying the Solid 2.0 pairing
32- // (TanStack/query#11326: named flight source, @solidjs/vite-plugin, the
33- // solid-js/web alias its vitest config needs to run against a 2.0 core);
34- // flip this to "TanStack/query" once it merges.
35- const QUERY_REPO = process . env . SOLID_QUERY_GATE_REPO ?? "ryansolid/query#feat/flight-data-source" ;
48+ // next core break the adapter people will install alongside it". That
49+ // adapter is @tanstack /solid-query 6 (the `rc` dist-tag), developed and
50+ // released from TanStack's `solid-query-v6-pre` branch — the Solid 2.0
51+ // pairing (TanStack/query#11326) merged there, not `main`, which still
52+ // carries the Solid 1.x adapter. Flip to "TanStack/query" when v6 lands on
53+ // main.
54+ const QUERY_REPO = process . env . SOLID_QUERY_GATE_REPO ?? "TanStack/query#solid-query-v6-pre" ;
3655
3756const CORE_PACKAGES = [ "signals" , "solid" , "web" ] as const ;
57+ // The compiler side of the contract. The fixture's @solidjs/vite-plugin
58+ // loads both: @solidjs /compiler in every mode (lazy/refresh/server-function
59+ // passes and, by default, JSX), @solidjs/babel-plugin for `compiler: "babel"`.
60+ const COMPILER_PACKAGES = [ "compiler" , "babel-plugin" ] as const ;
61+ // @solidjs /compiler's optionalDependencies pin platform binaries to THIS
62+ // version, which reaches the registry only after release.mjs publishes them
63+ // — after this gate. Resolve them to the in-repo stubs (no .node inside),
64+ // exactly as the workspace's own pnpm-workspace.yaml does, and hand the
65+ // loader the locally built binding through SOLID_COMPILER_NATIVE.
66+ const COMPILER_PLATFORMS = [
67+ "darwin-x64" ,
68+ "darwin-arm64" ,
69+ "linux-x64-gnu" ,
70+ "linux-arm64-gnu" ,
71+ "win32-x64-msvc" ,
72+ "wasm32-wasi"
73+ ] as const ;
74+
75+ const repoRoot = resolve ( join ( __dirname , "../../.." ) ) ;
76+ const packageRoot = ( dir : string ) => join ( repoRoot , "packages" , dir ) ;
3877
3978function pack ( packageRoot : string ) {
4079 const pkg = JSON . parse ( readFileSync ( join ( packageRoot , "package.json" ) , "utf8" ) ) ;
@@ -43,19 +82,75 @@ function pack(packageRoot: string) {
4382 return { name : pkg . name as string , path : join ( packageRoot , packedPkg ) } ;
4483}
4584
85+ // Newest mtime under a directory tree — the honest "when was this last
86+ // touched" for a source folder.
87+ function newestMtime ( dir : string ) : number {
88+ let newest = 0 ;
89+ for ( const entry of readdirSync ( dir , { withFileTypes : true } ) ) {
90+ const full = join ( dir , entry . name ) ;
91+ const mtime = entry . isDirectory ( ) ? newestMtime ( full ) : statSync ( full ) . mtimeMs ;
92+ if ( mtime > newest ) newest = mtime ;
93+ }
94+ return newest ;
95+ }
96+
97+ // The native binding `pnpm --filter @solidjs/compiler run build` leaves next
98+ // to index.js, in the loader's own preference order. The published package
99+ // ships no local binary (see its "files"), so the packed tarball needs this
100+ // handed to it explicitly.
101+ function locateCompilerBinding ( ) : string {
102+ const compilerDir = packageRoot ( "compiler" ) ;
103+ const { platform, arch } = process ;
104+ const suffix =
105+ platform === "darwin" && ( arch === "x64" || arch === "arm64" )
106+ ? `darwin-${ arch } `
107+ : platform === "linux" && ( arch === "x64" || arch === "arm64" )
108+ ? `linux-${ arch } -gnu`
109+ : platform === "win32" && arch === "x64"
110+ ? "win32-x64-msvc"
111+ : null ;
112+ const candidates = suffix ? [ `compiler.${ suffix } .node` , "compiler.node" ] : [ "compiler.node" ] ;
113+ const found = candidates . map ( file => join ( compilerDir , file ) ) . find ( existsSync ) ;
114+ if ( ! found ) {
115+ throw new Error (
116+ "packages/compiler has no native binding. Run `pnpm --filter @solidjs/compiler run build` first."
117+ ) ;
118+ }
119+ // A binding older than the compiler's sources would silently gate the
120+ // release on the previous compiler — the exact failure this gate exists
121+ // to catch. (CI builds it in the release job; this guards local runs.)
122+ if ( statSync ( found ) . mtimeMs < newestMtime ( join ( compilerDir , "src" ) ) ) {
123+ throw new Error (
124+ `${ found } is older than packages/compiler/src. Rebuild with \`pnpm --filter @solidjs/compiler run build\`.`
125+ ) ;
126+ }
127+ return found ;
128+ }
129+
46130describe ( "TanStack Solid Query against workspace-built core" , ( ) => {
47131 const queryRepoDir = resolve (
48132 join ( __dirname , "fixtures" , "downloaded" , QUERY_REPO . replace ( / [ # / ] / g, "-" ) )
49133 ) ;
50- let tarballs : Array < { name : string ; path : string } > ;
134+ let tarballs : Array < { name : string ; path : string } > = [ ] ;
135+ let compilerBinding : string ;
136+
137+ // The tarballs are packed into their package directories (untracked
138+ // there); pnpm has copied them into its store by the time the suite ran.
139+ afterAll ( ( ) => {
140+ for ( const { path } of tarballs ) rm ( "-f" , path ) ;
141+ } ) ;
51142
52143 beforeAll ( async ( ) => {
53144 for ( const dir of CORE_PACKAGES ) {
54- if ( ! existsSync ( resolve ( join ( __dirname , `../../ ${ dir } / dist` ) ) ) ) {
145+ if ( ! existsSync ( join ( packageRoot ( dir ) , " dist" ) ) ) {
55146 throw new Error ( `packages/${ dir } is not built. Run \`pnpm build\` first.` ) ;
56147 }
57148 }
58- tarballs = CORE_PACKAGES . map ( dir => pack ( resolve ( join ( __dirname , `../../${ dir } ` ) ) ) ) ;
149+ if ( ! existsSync ( join ( packageRoot ( "babel-plugin" ) , "index.js" ) ) ) {
150+ throw new Error ( "packages/babel-plugin is not built. Run `pnpm build` first." ) ;
151+ }
152+ compilerBinding = locateCompilerBinding ( ) ;
153+ tarballs = [ ...CORE_PACKAGES , ...COMPILER_PACKAGES ] . map ( dir => pack ( packageRoot ( dir ) ) ) ;
59154
60155 // Fresh download every run: the gate must see TanStack's current main,
61156 // and a stale extraction with a mutated lockfile would poison reruns.
@@ -72,7 +167,21 @@ describe("TanStack Solid Query against workspace-built core", () => {
72167 // pnpm.overrides is silently ignored there — measured, not assumed).
73168 const workspaceYamlPath = join ( queryRepoDir , "pnpm-workspace.yaml" ) ;
74169 const workspaceYaml = readFileSync ( workspaceYamlPath , "utf8" ) ;
75- const overrideLines = tarballs . map ( t => ` '${ t . name } ': 'file:${ t . path } '` ) . join ( "\n" ) ;
170+ // The fixture's own @solidjs/vite-plugin predates the switch from
171+ // @dom -expressions/compiler to @solidjs/compiler; older plugins ignore the
172+ // packed compiler entirely. Lift it to the plugin this tree is tested
173+ // with — the root devDependency, one source of truth — so the fixture is
174+ // compiled through the same plugin the examples and suites use.
175+ const vitePluginVersion = JSON . parse ( readFileSync ( join ( repoRoot , "package.json" ) , "utf8" ) )
176+ . devDependencies [ "@solidjs/vite-plugin" ] ;
177+ expect ( vitePluginVersion , "root devDependency @solidjs/vite-plugin" ) . toBeTruthy ( ) ;
178+ const overrideLines = [
179+ ...tarballs . map ( t => ` '${ t . name } ': 'file:${ t . path } '` ) ,
180+ ...COMPILER_PLATFORMS . map (
181+ p => ` '@solidjs/compiler-${ p } ': 'link:${ join ( packageRoot ( "compiler" ) , "npm" , p ) } '`
182+ ) ,
183+ ` '@solidjs/vite-plugin': '${ vitePluginVersion } '`
184+ ] . join ( "\n" ) ;
76185 if ( / ^ o v e r r i d e s : / m. test ( workspaceYaml ) ) {
77186 writeFileSync (
78187 workspaceYamlPath ,
@@ -112,13 +221,37 @@ describe("TanStack Solid Query against workspace-built core", () => {
112221 // nothing the registry could poison. When present it must be ours.
113222 const webLink = join ( solidQueryDir , "node_modules" , "@solidjs" , "web" ) ;
114223 if ( existsSync ( webLink ) ) fromTarball ( webLink , "@solidjs/web" ) ;
224+ // The compiler pair is requested by @solidjs/vite-plugin, not by
225+ // solid-query, so probe it through the plugin's own resolution — the
226+ // path the fixture's vite config actually loads.
227+ const vitePluginReal = realpathSync (
228+ join ( solidQueryDir , "node_modules" , "@solidjs" , "vite-plugin" )
229+ ) ;
230+ expect (
231+ JSON . parse ( readFileSync ( join ( vitePluginReal , "package.json" ) , "utf8" ) ) . version ,
232+ "@solidjs/vite-plugin was not lifted to the workspace's version"
233+ ) . toBe ( vitePluginVersion ) ;
234+ // (vitePluginReal is `<store>/node_modules/@solidjs/vite-plugin`; its
235+ // dependencies are siblings under the same scope directory.)
236+ for ( const name of [ "@solidjs/compiler" , "@solidjs/babel-plugin" ] ) {
237+ fromTarball ( join ( vitePluginReal , ".." , name . slice ( "@solidjs/" . length ) ) , name ) ;
238+ }
115239
116240 // The suite's typecheck half resolves @tanstack/query-core through
117241 // project references — dist-ts must exist (`tsc --build` follows the
118242 // reference graph).
119243 exec ( "pnpm run compile" , { cwd : solidQueryDir , fatal : true } ) ;
120244
121- const result = exec ( "npx vitest run" , { cwd : solidQueryDir , fatal : false } ) ;
122- expect ( result . code ) . toBe ( 0 ) ;
245+ // spawnSync, not shelljs: a runner that dies on a signal (V8's heap OOM
246+ // aborts) has no exit code, and shelljs reported that as 0 — a crashed
247+ // suite read as green. Judge the exit and the signal separately.
248+ const result = spawnSync ( "npx" , [ "vitest" , "run" ] , {
249+ cwd : solidQueryDir ,
250+ stdio : "inherit" ,
251+ env : { ...process . env , SOLID_COMPILER_NATIVE : compilerBinding }
252+ } ) ;
253+ expect ( result . error , "vitest could not be started" ) . toBeUndefined ( ) ;
254+ expect ( result . signal , "vitest was killed by a signal" ) . toBeNull ( ) ;
255+ expect ( result . status , "vitest exit status" ) . toBe ( 0 ) ;
123256 } , 900_000 ) ;
124257} ) ;
0 commit comments